summaryrefslogtreecommitdiffhomepage
path: root/include/ocl/basic_hash.hpp
blob: 1e58a5bcb1a4b5fce3affae0ba4e041b7f9294c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: BSL-1.0
// Copyright 2025-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Official repository: https://github.com/ocl-foss-org/core

#ifndef OCL_CORE_BASIC_HASH
#define OCL_CORE_BASIC_HASH

#include <ocl/detail/config.hpp>

/// @brief OCL equivalence namespace.
namespace ocl
{

	/// \brief Hash helper.
	template <class T>
	struct basic_hash
	{
		using result_type = typename T::result_type;
		using type		  = T;

		// AMLALE: If it throws, we can't compute the hash correctly.
		constexpr result_type hash() noexcept
		{
			return type{}.hash();
		}
	};

	/// \brief For all boolean types, return false as they are not hashable
	template <>
	struct basic_hash<bool>
	{
		using result_type = bool;
		using type		  = bool;

		// AMLALE: If it throws, we can't compute the hash correctly.
		constexpr result_type hash()
		{
			return false;
		}
	};

} // namespace ocl

#endif