Phi
is_same.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_SAME_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_SAME_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_same.hpp"
13 #include "phi/type_traits/integral_constant.hpp"
14 
15 DETAIL_PHI_BEGIN_NAMESPACE()
16 
17 #if PHI_SUPPORTS_IS_SAME()
18 
19 template <typename LhsT, typename RhsT>
20 struct is_same : public integral_constant<bool, PHI_IS_SAME(LhsT, RhsT)>
21 {};
22 
23 template <typename LhsT, typename RhsT>
24 struct is_not_same : public integral_constant<bool, !PHI_IS_SAME(LhsT, RhsT)>
25 {};
26 
27 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
28 
29 template <typename LhsT, typename RhsT>
30 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_same_v = PHI_IS_SAME(LhsT, RhsT);
31 
32 template <typename LhsT, typename RhsT>
33 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_same_v = !PHI_IS_SAME(LhsT, RhsT);
34 
35 # endif
36 
37 #else
38 
39 template <typename LhsT, typename RhsT>
40 struct is_same : public false_type
41 {};
42 
43 template <typename TypeT>
44 struct is_same<TypeT, TypeT> : public true_type
45 {};
46 
47 template <typename TypeT, typename OtherT>
48 struct is_not_same : public true_type
49 {};
50 
51 template <typename TypeT>
52 struct is_not_same<TypeT, TypeT> : public false_type
53 {};
54 
55 # if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
56 
57 template <typename LhsT, typename RhsT>
58 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_same_v = is_same<LhsT, RhsT>::value;
59 
60 template <typename TypeT, typename OtherT>
61 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_same_v = is_not_same<TypeT, OtherT>::value;
62 
63 # endif
64 
65 #endif
66 
67 DETAIL_PHI_END_NAMESPACE()
68 
69 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_SAME_HPP
Definition: integral_constant.hpp:19
Definition: is_same.hpp:48
Definition: is_same.hpp:40