Phi
is_union.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_UNION_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_UNION_HPP
3 
4 #include "phi/phi_config.hpp"
5 
6 #if PHI_HAS_EXTENSION_PRAGMA_ONCE()
7 # pragma once
8 #endif
9 
10 #include "phi/compiler_support/constexpr.hpp"
11 #include "phi/compiler_support/inline_variables.hpp"
12 #include "phi/compiler_support/intrinsics/is_union.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 #if PHI_SUPPORTS_IS_UNION()
16 
17 # define PHI_HAS_WORKING_IS_UNION() 1
18 
19 DETAIL_PHI_BEGIN_NAMESPACE()
20 
21 template <typename TypeT>
22 struct is_union : public integral_constant<bool, PHI_IS_UNION(TypeT)>
23 {};
24 
25 template <typename TypeT>
26 struct is_not_union : public integral_constant<bool, !PHI_IS_UNION(TypeT)>
27 {};
28 
29 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
30 
31 template <typename TypeT>
32 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_union_v = PHI_IS_UNION(TypeT);
33 
34 template <typename TypeT>
35 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_union_v = !PHI_IS_UNION(TypeT);
36 
37 # endif
38 
39 #else
40 
41 # include "phi/type_traits/false_t.hpp"
42 
43 # define PHI_HAS_WORKING_IS_UNION() 0
44 
45 DETAIL_PHI_BEGIN_NAMESPACE()
46 
47 template <typename TypeT>
48 struct is_union : public false_type
49 {
50  static_assert(false_t<TypeT>::value,
51  "phi::is_union requires compiler support to properly work.");
52 };
53 
54 template <typename TypeT>
55 struct is_not_union : public integral_constant<bool, !is_union<TypeT>::value>
56 {};
57 
58 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
59 
60 template <typename TypeT>
61 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_union_v = is_union<TypeT>::value;
62 
63 template <typename TypeT>
64 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_union_v = is_not_union<TypeT>::value;
65 
66 # endif
67 
68 #endif
69 
70 DETAIL_PHI_END_NAMESPACE()
71 
72 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_UNION_HPP
Definition: integral_constant.hpp:19
Definition: is_union.hpp:55
Definition: false_t.hpp:29
Definition: is_union.hpp:48