Phi
is_const.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_CONST_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_CONST_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_const.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 DETAIL_PHI_BEGIN_NAMESPACE()
16 
17 #if PHI_SUPPORTS_IS_CONST()
18 
19 template <typename TypeT>
20 struct is_const : public integral_constant<bool, PHI_IS_CONST(TypeT)>
21 {};
22 
23 template <typename TypeT>
24 struct is_not_const : public integral_constant<bool, !PHI_IS_CONST(TypeT)>
25 {};
26 
27 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
28 
29 template <typename TypeT>
30 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_const_v = PHI_IS_CONST(TypeT);
31 
32 template <typename TypeT>
33 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_const_v = !PHI_IS_CONST(TypeT);
34 
35 # endif
36 
37 #else
38 
39 template <typename TypeT>
40 struct is_const : public false_type
41 {};
42 
43 template <typename TypeT>
44 struct is_const<const TypeT> : public true_type
45 {};
46 
47 template <typename TypeT>
48 struct is_not_const : public integral_constant<bool, !is_const<TypeT>::value>
49 {};
50 
51 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
52 
53 template <typename TypeT>
54 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_const_v = is_const<TypeT>::value;
55 
56 template <typename TypeT>
57 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_const_v = is_not_const<TypeT>::value;
58 
59 # endif
60 
61 #endif
62 
63 DETAIL_PHI_END_NAMESPACE()
64 
65 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_CONST_HPP
Definition: integral_constant.hpp:19
Definition: is_const.hpp:40
Definition: is_const.hpp:48