Phi
integral_constant.hpp
1 #ifndef INCG_PHI_CORE_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
2 #define INCG_PHI_CORE_TYPE_TRAITS_INTEGRAL_CONSTANT_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.hpp"
12 #include "phi/compiler_support/nodiscard.hpp"
13 #include "phi/compiler_support/noexcept.hpp"
14 
15 DETAIL_PHI_BEGIN_NAMESPACE()
16 
17 // 21.3.4 Helper classes, https://eel.is/c++draft/type.traits#meta.help
18 template <typename TypeT, TypeT Value>
20 {
22  using value_type = TypeT;
24 
25  static PHI_CONSTEXPR_AND_CONST TypeT value = Value;
26 
27  PHI_NODISCARD PHI_ALWAYS_INLINE PHI_CONSTEXPR operator TypeT() const PHI_NOEXCEPT
28  {
29  return value;
30  }
31 
32  PHI_NODISCARD PHI_ALWAYS_INLINE PHI_CONSTEXPR TypeT operator()() const PHI_NOEXCEPT
33  {
34  return value;
35  }
36 };
37 
38 #if PHI_CPP_STANDARD_IS_BELOW(17)
39 
40 template <typename TypeT, TypeT Value>
41 PHI_CONSTEXPR_AND_CONST TypeT
42  integral_constant<TypeT, Value>::value; // NOLINT(readability-redundant-declaration)
43 
44 #endif
45 
48 
49 DETAIL_PHI_END_NAMESPACE()
50 
51 #endif // INCG_PHI_CORE_TYPE_TRAITS_INTEGRAL_CONSTANT_HPP
Definition: integral_constant.hpp:19