GLSL Struct 1.4.8
glslstruct
Loading...
Searching...
No Matches
hash.hpp
1/*
2 * glslstruct - a C++ library designed to easily represent GLSL's Uniform Buffer Objects (UBOs) and Shader Storage Buffer Objects (SSBOs) in C++.
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/glslstruct/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 */
9
10#pragma once
11#ifndef _GLSL_STRUCT_HASH_HPP_
12 #define _GLSL_STRUCT_HASH_HPP_
13
14 #include <glslstruct/config.hpp>
15
17_GLSL_STRUCT_ERROR("This is only available for c++17 and greater!");
18 #else
19
20 #include <glslstruct/libs.hpp>
21
22namespace glslstruct::utils {
24 /**
25 * @brief Checks if type has defined std::hash
26 * @ingroup utils
27 * @tparam T type
28 */
29 template<class T> concept hashable = requires { typename std::hash<T>; };
30
31 /**
32 * @brief Checks if type has defined std::hash
33 * @ingroup utils
34 * @tparam T type
35 */
36 template<class T>
37 static _GLSL_STRUCT_CONSTEXPR17 bool is_hashable_v = hashable<T>;
38
39 /**
40 * @brief Checks if type has defined std::hash
41 * @ingroup utils
42 * @tparam T type
43 */
44 template<class T>
45 struct is_hashable : std::bool_constant<is_hashable_v<T> > {};
46 #else
47 /**
48 * @brief Checks if type has defined std::hash
49 * @ingroup utils
50 * @tparam T type
51 */
52 template<class T, class = void>
53 struct is_hashable : std::false_type {};
54
55 /**
56 * @brief Checks if type has defined std::hash
57 * @ingroup utils
58 * @tparam T type
59 */
60 template<class T>
61 struct is_hashable<T, std::void_t<std::hash<T> > > : std::true_type {};
62
63 /**
64 * @brief Checks if type has defined std::hash
65 * @ingroup utils
66 * @tparam T type
67 */
68 template<class T>
69 static _GLSL_STRUCT_CONSTEXPR17 bool is_hashable_v = is_hashable<T>::value;
70 #endif
71} // namespace glslstruct::utils
72
73 #endif
74#endif
#define _GLSL_STRUCT_HAS_CXX20
check if compiler has c++ version greater or equal to c++20 and if user enabled c++20 features using ...
Definition config.hpp:142
#define _GLSL_STRUCT_HAS_CXX17
check if compiler has c++ version greater or equal to c++17
Definition config.hpp:130
#define _GLSL_STRUCT_CONSTEXPR17
constexpr for c++17 and higher
Definition config.hpp:196