Phi
is_reference.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_REFERENCE_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_REFERENCE_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_reference.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 DETAIL_PHI_BEGIN_NAMESPACE()
16 
17 #if PHI_SUPPORTS_IS_REFERENCE()
18 
19 template <typename TypeT>
20 struct is_reference : public integral_constant<bool, PHI_IS_REFERENCE(TypeT)>
21 {};
22 
23 template <typename TypeT>
24 struct is_not_reference : public integral_constant<bool, !PHI_IS_REFERENCE(TypeT)>
25 {};
26 
27 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
28 
29 template <typename TypeT>
30 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_reference_v = PHI_IS_REFERENCE(TypeT);
31 
32 template <typename TypeT>
33 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_reference_v = !PHI_IS_REFERENCE(TypeT);
34 
35 # endif
36 
37 #else
38 
39 template <typename TypeT>
40 struct is_reference : public false_type
41 {};
42 
43 // l-value reference
44 template <typename TypeT>
45 struct is_reference<TypeT&> : public true_type
46 {};
47 
48 // r-value reference
49 template <typename TypeT>
50 struct is_reference<TypeT&&> : public true_type
51 {};
52 
53 template <typename TypeT>
54 struct is_not_reference : public integral_constant<bool, !is_reference<TypeT>::value>
55 {};
56 
57 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
58 
59 template <typename TypeT>
60 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_reference_v = is_reference<TypeT>::value;
61 
62 template <typename TypeT>
63 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_reference_v = is_not_reference<TypeT>::value;
64 
65 # endif
66 
67 #endif
68 
69 DETAIL_PHI_END_NAMESPACE()
70 
71 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_REFERENCE_HPP
Definition: integral_constant.hpp:19
Definition: is_reference.hpp:54
Definition: is_reference.hpp:40