Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
qx-typetraits.h
Go to the documentation of this file.
1#ifndef QX_TYPETRAITS_H
2#define QX_TYPETRAITS_H
3
4// Standard Library Includes
5#include <type_traits>
6
7namespace Qx
8{
9
10// Specialization
11template <class A, template <typename...> class B>
12struct is_specialization_of : std::false_type {};
13
14template <typename... Args, template <typename...> class B>
15struct is_specialization_of<B<Args...>, B> : std::true_type {};
16
17template <typename A, template <typename...> class B>
19
20// Containers
21template <typename T>
22struct unwrap { using type = T; };
23
24template <typename T>
25 requires requires { typename T::value_type; }
26struct unwrap<T> { using type = typename T::value_type; };
27
28template <typename T>
29 requires requires { typename T::mapped_type; } && (!requires { typename T::value_type; })
30struct unwrap<T> { using type = typename T::mapped_type; };
31
32template<typename T>
33using unwrap_t = typename unwrap<T>::type;
34
35// Qualifiers
36template<typename T>
37using target_type = std::remove_pointer_t<std::remove_reference_t<T>>;
38
39// Misc
40template<class... T>
41inline constexpr bool always_false = false;
42
43}
44
45#endif // QX_TYPETRAITS_H
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-abstracterror.cpp:13
constexpr bool always_false
Definition qx-typetraits.h:41
std::remove_pointer_t< std::remove_reference_t< T > > target_type
Definition qx-typetraits.h:37
constexpr bool is_specialization_of_v
See is_specialization_of.
Definition qx-typetraits.h:18
typename unwrap< T >::type unwrap_t
See unwrap.
Definition qx-typetraits.h:33
Checks whether A is a specialization of B.
Definition qx-typetraits.h:12
Provides the inner type of T if T wraps or contains another type; otherwise, provides T itself.
Definition qx-typetraits.h:22
T type
Definition qx-typetraits.h:22