遇见YY

导航

 

头文件:#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)的基类。

  • Member constants
Type Definition
value_type T
type std::integral_constant<T,v>
  • Member constants
Name Value
constanexpr T value [static] static constant of type T with value v (public static member constant)
  • Member function
operator value_type
operator value_type returns the wrapped value (public member function)
operator() returns the wrapped value (public member function)
posted on 2021-01-14 20:26  一骑红尘妃子笑!  阅读(198)  评论(0编辑  收藏  举报