LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
traits.hpp
1#pragma once
2
3#include <type_traits>
4#include <typeindex>
5#include <concepts>
6
7#ifndef __cpp_size_t_suffix
8// Implements C++23 P0330R8 for when compiler is missing support (MSVC only).
9#pragma warning(suppress: 4455) // Ignore warning about reserved suffix, as this is guarded anyway.
10inline constexpr std::size_t operator"" uz(unsigned long long int k)
11{
12 return static_cast<std::size_t>(k);
13}
14#endif
15
19namespace LiteFX::meta {
20
24 template <class, class = std::void_t<>>
25 struct has_builder_t : std::false_type { };
26
30 template<class T>
31 struct has_builder_t<T, std::void_t<typename T::builder>> : std::true_type { };
32
47 template <class T>
49
55 template <class T>
57
64 template <typename T, typename TArg, typename ...TArgs>
65 struct is_explicitly_constructible_t : std::bool_constant<std::is_constructible_v<T, TArg, TArgs...> && !std::is_convertible_v<TArg, T>> { };
66
73 template <typename T, typename TArg, typename ...TArgs>
74 constexpr bool is_explicitly_constructible_v = is_explicitly_constructible_t<T, TArg, TArgs...>::value;
75
82 template <typename T, typename TArg, typename ...TArgs>
84
91 template <typename T, typename TArg, typename ...TArgs>
92 struct is_implicitly_constructible_t : std::bool_constant<std::is_constructible_v<T, TArg, TArgs...> && std::is_convertible_v<TArg, T>> { };
93
100 template <typename T, typename TArg, typename ...TArgs>
101 constexpr bool is_implicitly_constructible_v = is_explicitly_constructible_t<T, TArg, TArgs...>::value;
102
109 template <typename T, typename TArg, typename ...TArgs>
111
117 template <typename TDerived, typename TBase>
118 concept implements = !std::is_abstract_v<TDerived> && std::derived_from<TDerived, TBase>;
119
125 template <typename T, typename... Ts>
126 concept are_same = std::conjunction_v<std::is_same<T, Ts>...>;
127
128}
Checks if a set of types are all equal to the type T .
Definition traits.hpp:126
Checks if a type contains a builder.
Definition traits.hpp:56
Checks if a type TDerived is derived from another type TBase and is non-abstract.
Definition traits.hpp:118
Checks if a type can be constructed using the provided arguments, whilst not being able to be convert...
Definition traits.hpp:83
Checks if a type can be constructed using the provided arguments and at the same time can also be con...
Definition traits.hpp:110
Contains type traits and meta-programming features for compile-time evaluation.
Definition traits.hpp:19
constexpr bool has_builder_v
Evaluates to either true or false, if T contains an builder member definition.
Definition traits.hpp:48
constexpr bool is_explicitly_constructible_v
Evalues to true or false, depending if T contains an explicit constructor that takes TArg and TArgs...
Definition traits.hpp:74
constexpr bool is_implicitly_constructible_v
Evalues to true or false, depending if T contains an implicit constructor that takes TArg and TArgs...
Definition traits.hpp:101
Trait that is evaluated, if a class does not have an builder member type defined.
Definition traits.hpp:25
Evaluates to either true or false, if T can be constructed using the provided arguments,...
Definition traits.hpp:65
Evaluates to either true or false, if T can be constructed using the provided arguments and at the s...
Definition traits.hpp:92