Phi
is_final.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_FINAL_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_FINAL_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_final.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 #if PHI_SUPPORTS_IS_FINAL()
16 
17 DETAIL_PHI_BEGIN_NAMESPACE()
18 
19 # define PHI_HAS_WORKING_IS_FINAL() 1
20 
21 template <typename TypeT>
22 struct is_final : public integral_constant<bool, PHI_IS_FINAL(TypeT)>
23 {};
24 
25 template <typename TypeT>
26 struct is_not_final : public integral_constant<bool, !PHI_IS_FINAL(TypeT)>
27 {};
28 
29 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
30 
31 template <typename TypeT>
32 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_final_v = PHI_IS_FINAL(TypeT);
33 
34 template <typename TypeT>
35 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_final_v = !PHI_IS_FINAL(TypeT);
36 
37 # endif
38 
39 #else
40 
41 # include "phi/type_traits/false_t.hpp"
42 
43 # define PHI_HAS_WORKING_IS_FINAL() 0
44 
45 DETAIL_PHI_BEGIN_NAMESPACE()
46 
47 template <typename TypeT>
48 struct is_final : public false_type
49 {
50  static_assert(false_t<TypeT>::value,
51  "phi::is_final requires compiler support for intrinsic __is_final");
52 };
53 
54 template <typename TypeT>
55 struct is_not_final : public false_type
56 {
57  static_assert(false_t<TypeT>::value,
58  "phi::is_not_final requires compiler support for intrinsic __is_final");
59 };
60 
61 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
62 
63 template <typename TypeT>
64 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_final_v = is_final<TypeT>::value;
65 
66 template <typename TypeT>
67 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_final_v = is_not_final<TypeT>::value;
68 
69 # endif
70 
71 #endif
72 
73 DETAIL_PHI_END_NAMESPACE()
74 
75 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_FINAL_HPP
Definition: integral_constant.hpp:19
Definition: is_final.hpp:48
Definition: false_t.hpp:29
Definition: is_final.hpp:55