GLSL Struct 1.4.0
glslstruct
Loading...
Searching...
No Matches
layouts_checks.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_LAYOUT_CHECKS_HPP_
12 #define _GLSL_STRUCT_LAYOUT_CHECKS_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/layout/traits/layout_traits_concept.hpp>
21 #include <glslstruct/layout/traits/scalar_layout_traits.hpp>
22 #include <glslstruct/layout/traits/std140_layout_traits.hpp>
23 #include <glslstruct/layout/traits/std430_layout_traits.hpp>
24 #include <glslstruct/type/checks/simple_checks.hpp>
25
26namespace glslstruct {
28 template<layout_traits T>
29 #else
30 template<class T, std::enable_if_t<is_layout_traits_v<T>, bool> = true>
31 #endif
32 class base_layout;
33
34 /**
35 * @brief std140 layout representation
36 * @ingroup glslstruct
37 */
38 using std140_layout = base_layout<std140_layout_traits>;
39 /**
40 * @brief std430 layout representation
41 * @ingroup glslstruct
42 */
43 using std430_layout = base_layout<std430_layout_traits>;
44 /**
45 * @brief scalar layout representation
46 * @ingroup glslstruct
47 */
48 using scalar_layout = base_layout<scalar_layout_traits>;
49
50 namespace utils {
51 #pragma region IS_LAYOUT
52
53 /**
54 * @brief helper struct to check if type is glsl layout
55 * @ingroup utils
56 * @tparam T type which is glsl layout type
57 */
58 template<class T>
59 struct is_glsl_layout : std::false_type {};
60
61 template<class T>
62 struct is_glsl_layout<base_layout<T> > : std::true_type {};
63
64 /**
65 * @brief check if type is glsl layout
66 * @ingroup utils
67 * @tparam T type which is glsl layout type
68 */
69 template<class T>
70 static _GLSL_STRUCT_CONSTEXPR17 bool is_glsl_layout_v = is_glsl_layout<T>::value;
71
73 /**
74 * @brief check if type is glsl layout
75 * @ingroup utils
76 * @tparam T type which is glsl layout type
77 */
78 template<class T> concept glsl_layout = is_glsl_layout_v<T>;
79 #endif
80 #pragma endregion
81
82 #pragma region IS_SIMPLE_OR_LAYOUT
83 /**
84 * @brief check if type is glsl layout or glsl simple
85 * @ingroup utils
86 * @tparam T type which is glsl layout or simple type
87 */
88 template<class T>
89 static _GLSL_STRUCT_CONSTEXPR17 bool is_glsl_simple_or_layout_v = is_glsl_simple_v<T> || is_glsl_layout_v<T>;
90
92 /**
93 * @brief check if type is glsl layout or glsl simple
94 * @ingroup utils
95 * @tparam T type which is glsl layout or simple type
96 */
97 template<class T> concept glsl_simple_or_layout = is_glsl_simple_or_layout_v<T>;
98 #endif
99 #pragma endregion
100 } // namespace utils
101} // namespace glslstruct
102 #endif
103#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