Namespaces
Variants

Variable templates for type traits (library fundamentals TS)

From cppreference.net

C++ 库基础扩展版本 1 提供了多个用于类型特征类的 constexpr 变量模板,以及其他具有公开 ::value 成员的类似类模板。

除非另有说明,以下变量模板均定义在 std::experimental 命名空间中。

目录

类型特征

基本类型分类
变量模板
定义于头文件 <experimental/type_traits>
template < class T > constexpr bool is_void_v = std:: is_void < T > :: value ;
template < class T > constexpr bool is_null_pointer_v = std:: is_null_pointer < T > :: value ;
template < class T > constexpr bool is_integral_v = std:: is_integral < T > :: value ;
template < class T > constexpr bool is_floating_point_v = std:: is_floating_point < T > :: value ;
template < class T > constexpr bool is_array_v = std:: is_array < T > :: value ;
template < class T > constexpr bool is_pointer_v = std:: is_pointer < T > :: value ;
template < class T > constexpr bool is_lvalue_reference_v = std:: is_lvalue_reference < T > :: value ;
template < class T > constexpr bool is_rvalue_reference_v = std:: is_rvalue_reference < T > :: value ;
template < class T > constexpr bool is_member_object_pointer_v = std:: is_member_object_pointer < T > :: value ;
template < class T > constexpr bool is_member_function_pointer_v = std:: is_member_function_pointer < T > :: value ;
template < class T > constexpr bool is_enum_v = std:: is_enum < T > :: value ;
template < class T > constexpr bool is_union_v = std:: is_union < T > :: value ;
template < class T > constexpr bool is_class_v = std:: is_class < T > :: value ;
template < class T > constexpr bool is_function_v = <span class
支持的操作
变量模板
定义于头文件 <experimental/type_traits>
template < class T, class ... Args > constexpr bool is_constructible_v = std:: is_constructible < T, Args... > :: value ;
template < class T, class ... Args > constexpr bool is_trivially_constructible_v = std:: is_trivially_constructible < T, Args... > :: value ;
template < class T, class ... Args > constexpr bool is_nothrow_constructible_v = std:: is_nothrow_constructible < T, Args... > :: value ;
template < class T > constexpr bool is_default_constructible_v = std:: is_default_constructible < T > :: value ;
template < class T > constexpr bool is_trivially_default_constructible_v = std:: is_trivially_default_constructible < T > :: value ;
template < class T > constexpr bool is_nothrow_default_constructible_v = std:: is_nothrow_default_constructible < T > :: value ;
template < class T > constexpr bool is_copy_constructible_v = std:: is_copy_constructible < T > :: value ;
template < class T > constexpr bool is_trivially_copy_constructible_v = std:: is_trivially_copy_constructible < T > :: value ;
template < class T > constexpr bool is_nothrow_copy_constructible_v = std:: is_nothrow_copy_constructible < T > :: value ;
template < class T > constexpr bool is_move_constructible_v = std:: is_move_constructible < T > :: value ;
template < class T > constexpr bool is_trivially_move_constructible_v = std:: is_trivially_move_constructible < T > :: value ;
template < class T > constexpr bool is_nothrow_move_constructible_v = std:: is_nothrow_move_constructible < T > :: value ;
template < class T, class U > constexpr bool is_assignable_v = std:: is_assignable < T, U > :: value ;
template < class T, class U > constexpr bool is_trivially_assignable_v = std:: is_trivially_assignable < T, U > :: value ;
template < class T, class U > constexpr bool is_nothrow_assignable_v = std:: is_nothrow_assignable < T, U > :: value ;
template < <
属性查询
变量模板
定义于头文件 <experimental/type_traits>
template < class T > constexpr std:: size_t alignment_of_v = std:: alignment_of < T > :: value ;
template < class T > constexpr std:: size_t rank_v = std:: rank < T > :: value ;
template < class T, unsigned I = 0 > constexpr std:: size_t extent_v = std:: extent < T, I > :: value ;
类型关系
变量模板
定义于头文件 <experimental/type_traits>
template < class T, class U > constexpr bool is_same_v = std:: is_same < T, U > :: value ;
template < class Base, class Derived > constexpr bool is_base_of_v = std:: is_base_of < Base, Derived > :: value ;
template < class From, class To > constexpr bool is_convertible_v = std:: is_convertible < From, To > :: value ;

其他变量模板

std::ratio 比较
变量模板
定义于头文件 <experimental/ratio>
template < class R1, class R2 > constexpr bool ratio_equal_v = std:: ratio_equal < R1, R2 > :: value ;
template < class R1, class R2 > constexpr bool ratio_not_equal_v = std:: ratio_not_equal < R1, R2 > :: value ;
template < class R1, class R2 > constexpr bool ratio_less_v = std:: ratio_less < R1, R2 > :: value ;
template < class R1, class R2 > constexpr bool ratio_less_equal_v = std:: ratio_less_equal < R1, R2 > :: value ;
template < class R1, class R2 > constexpr bool ratio_greater_v = std:: ratio_greater < R1, R2 > :: value ;
template < class R1, class R2 > constexpr bool ratio_greater_equal_v = std:: ratio_greater_equal < R1, R2 > :: value ;
杂项
变量模板
定义于头文件 <experimental/tuple>
template < class T > constexpr std:: size_t tuple_size_v = std:: tuple_size < T > :: value ;

注释

[1]: 定义于 std::chrono::experimental 命名空间中。