Phi
is_unscoped_enum.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_IS_UNSCOPED_ENUM_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_IS_UNSCOPED_ENUM_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/type_traits/integral_constant.hpp"
13 #include "phi/type_traits/is_convertible.hpp"
14 #include "phi/type_traits/is_enum.hpp"
15 #include "phi/type_traits/to_underlying.hpp"
16 
17 DETAIL_PHI_BEGIN_NAMESPACE()
18 
19 #if PHI_HAS_WORKING_IS_ENUM() && PHI_HAS_WORKING_UNDERLYING_TYPE()
20 # define PHI_HAS_WORKING_IS_UNSCOPED_ENUM() 1
21 #else
22 # define PHI_HAS_WORKING_IS_UNSCOPED_ENUM() 0
23 #endif
24 
25 namespace detail
26 {
27  template <typename TypeT, bool IsEnum>
29  {};
30 
31  template <typename TypeT>
32  struct is_unscoped_enum_impl<TypeT, true>
33  : public integral_constant<bool, is_convertible<TypeT, underlying_type_t<TypeT>>::value>
34  {};
35 } // namespace detail
36 
37 template <typename TypeT>
38 struct is_unscoped_enum : public detail::is_unscoped_enum_impl<TypeT, is_enum<TypeT>::value>
39 {};
40 
41 template <typename TypeT>
42 struct is_not_unscoped_enum : public integral_constant<bool, !is_unscoped_enum<TypeT>::value>
43 {};
44 
45 #if PHI_HAS_FEATURE_VARIABLE_TEMPLATE()
46 
47 template <typename TypeT>
48 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_unscoped_enum_v = is_unscoped_enum<TypeT>::value;
49 
50 template <typename TypeT>
51 PHI_INLINE_VARIABLE PHI_CONSTEXPR bool is_not_unscoped_enum_v = is_not_unscoped_enum<TypeT>::value;
52 
53 #endif
54 
55 DETAIL_PHI_END_NAMESPACE()
56 
57 #endif // INCG_PHI_CORE_TYPE_TRAITS_IS_UNSCOPED_ENUM_HPP
Definition: integral_constant.hpp:19
Definition: is_unscoped_enum.hpp:42
Definition: is_unscoped_enum.hpp:38
Definition: swap.hpp:23
Definition: is_unscoped_enum.hpp:28