头文件:#include<type_traits>
可能的实现:
template<class T,T v>
struct integral_constant{
static constexpr T value = v;
using value_type = T;
using type = integral_constant;
constexpr operator value_type() const noexcept { return value; }
constexpr value_type operator()() const noexcept { return value; } // if __cplusplus > 201103L.
}
std::integral_constant 包装(wrap)一个指定类型T的一个静态常量,它是C++类型特征(The C++ type traits)的基类。
Type |
Definition |
value_type |
T |
type |
std::integral_constant<T,v> |
Name |
Value |
constanexpr T value [static] |
static constant of type T with value v (public static member constant) |
operator |
value_type |
operator value_type |
returns the wrapped value (public member function) |
operator() |
returns the wrapped value (public member function) |