编程语言
首页 > 编程语言> > C++ std::integral_constant

C++ std::integral_constant

作者:互联网

头文件:#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)

标签:std,constant,integral,value,static,operator,type
来源: https://www.cnblogs.com/iuyy/p/14279181.html