Mountain  1.0.0
Simple C++ 2D Game Framework
meta_programming.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 // ReSharper disable CppInconsistentNaming
4 
8 
9 #include "Mountain/core.hpp"
10 
11 #include <map>
12 #include <type_traits>
13 
14 #include <Maths/quaternion.hpp>
15 #include <Maths/vector2.hpp>
16 #include <Maths/vector3.hpp>
17 
19 
20 namespace Mountain
21 {
22  template <typename>
23  class Pointer;
24  template <typename>
25  class List;
26 
29  namespace Meta
30  {
34  template <typename Base, typename Derived>
35  constexpr bool_t IsBaseOf = std::is_base_of_v<Base, Derived>;
36 
40  template <typename A, typename B>
41  constexpr bool_t IsSame = std::is_same_v<A, B>;
42 
46  template <typename T, typename... Other>
47  constexpr bool_t IsAny = (std::is_same_v<T, Other> || ...);
48 
51  template <typename T>
52  constexpr bool_t IsArray = std::is_array_v<T>;
53 
56  template <typename T>
57  constexpr bool_t IsPointer = std::is_pointer_v<T>;
58 
61  template <typename T>
62  constexpr bool_t IsClass = std::is_class_v<T>;
63 
66  template <typename T>
67  constexpr bool_t IsEnum = std::is_enum_v<T>;
68 
71  template <typename T>
72  constexpr bool_t IsIntegral = std::is_integral_v<T>;
73 
76  template <typename T>
77  constexpr bool_t IsFloatingPoint = std::is_floating_point_v<T>;
78 
81  template <typename T>
82  constexpr bool_t IsAbstract = std::is_abstract_v<T>;
83 
86  template <typename T>
87  constexpr bool_t IsDefaultConstructible = std::is_default_constructible_v<T>;
88 
91  template <typename T>
92  constexpr bool_t IsCopyAssignable = std::is_copy_assignable_v<T>;
93 
94  template <bool_t Test>
95  using EnableIf = std::enable_if_t<Test>;
96 
101  template <typename T>
102  using RemoveArraySpecifier = std::remove_extent_t<T>;
103 
108  template <typename T>
109  using RemovePointerSpecifier = std::remove_pointer_t<T>;
110 
115  template <typename T>
116  using RemoveConstSpecifier = std::remove_const_t<T>;
117 
119  template <typename>
120  constexpr bool_t IsStdVector = false;
121 
122  template <typename T, typename A>
123  constexpr bool_t IsStdVector<std::vector<T, A>> = true;
124 
126  template <typename>
127  constexpr bool_t IsStdFunction = false;
128 
129  template <typename T, typename... Args>
130  constexpr bool_t IsStdFunction<std::function<T(Args...)>> = true;
131 
133  template <typename>
134  constexpr bool_t IsStdMap = false;
135 
136  template <typename T, typename A>
137  constexpr bool_t IsStdMap<std::map<T, A>> = true;
138 
140  template <typename>
141  constexpr bool_t IsMountainList = false;
142 
143  template <typename T>
144  constexpr bool_t IsMountainList<List<T>> = true;
145 
147  template <typename>
148  constexpr bool_t IsMountainPointer = false;
149 
151  template <typename T>
152  constexpr bool_t IsMountainPointer<Pointer<T>> = true;
153 
168  template <typename T>
169  constexpr bool_t IsNativeType = IsAny<T, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float_t, double_t, bool_t>;
170 
184  template <typename T>
185  constexpr bool_t IsIntegralOrFloating = IsAny<T, uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float_t, double_t>;
186 
197  template <typename T>
198  constexpr bool_t IsMathType = IsAny<T, Vector2, Vector2i, Vector3, Vector4, Quaternion>;
199 
207  template <typename T>
208  constexpr bool_t IsColorType = IsAny<T, Color, ColorHsva>;
209 
210  template <Concepts::EnumT T>
211  using UnderlyingEnumType = std::underlying_type_t<T>;
212 
213  template <Concepts::EnumT T>
214  using Flags = UnderlyingEnumType<T>;
215  }
216 };
constexpr bool_t IsEnum
Checks whether T is an enum.
constexpr bool_t IsSame
Checks whether A and B are the same type.
constexpr bool_t IsMountainPointer
Checks whether the type is a Pointer.
std::remove_extent_t< T > RemoveArraySpecifier
Removes the array specification from T.
constexpr bool_t IsDefaultConstructible
Checks whether T is default constructible (has a public constructor, with no parameters) ...
constexpr bool_t IsIntegral
Checks whether T is an integral type.
constexpr bool_t IsClass
Checks whether T is a class.
constexpr bool_t IsFloatingPoint
Checks whether T is a floating type.
constexpr bool_t IsAbstract
Checks whether T is an abstract class.
constexpr bool_t IsAny
Checks whether T is any of the provided types in Other.
constexpr bool_t IsStdFunction
Checks whether the type is a std::vector.
constexpr bool_t IsPointer
Checks whether T is a pointer.
std::remove_pointer_t< T > RemovePointerSpecifier
Removes the pointer specification from T.
constexpr bool_t IsArray
Checks whether T is an array.
constexpr bool_t IsStdVector
Checks whether the type is a std::vector.
Custom Mountain smart pointer. Represents both a std::shared_ptr and a std::weak_ptr.
constexpr bool_t IsColorType
Checks if T is a color type.
constexpr bool_t IsNativeType
Checks if T is a native type.
Defines utilities for meta programming and template manipulation.
Defines the Mountain::Concepts namespace which contains useful concepts used in the engine...
constexpr bool_t IsBaseOf
Checks whether Derived is a derived class of Base.
std::remove_const_t< T > RemoveConstSpecifier
Removes the const specification from T.
constexpr bool_t IsMathType
Checks if T is a math type.
constexpr bool_t IsCopyAssignable
Checks whether T can be copied without semantics.
constexpr bool_t IsStdMap
Checks whether the type is a std::vector.
constexpr bool_t IsMountainList
Checks whether the type is a List.
constexpr bool_t IsIntegralOrFloating
Checks if T is an integral or a floating type.
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22