类型特征的变量模板 (库基础 TS)

来自cppreference.com


C++ 库基础扩展版本 1 为类型特征类和其他类似的带有公开 {tt|::value}} 成员的类模板提供了许多 constexpr 变量模板。

除非另行注明,下列变量模板定义于 std::experimental 命名空间。

目录

类型特征

基本类型分类
变量模板
在标头 <experimental/type_traits> 定义
template<class T>constexprbool is_void_v =std::is_void<T>::value;
template<class T>constexprbool is_null_pointer_v =std::is_null_pointer<T>::value;
template<class T>constexprbool is_integral_v =std::is_integral<T>::value;
template<class T>constexprbool is_floating_point_v =std::is_floating_point<T>::value;
template<class T>constexprbool is_array_v =std::is_array<T>::value;
template<class T>constexprbool is_pointer_v =std::is_pointer<T>::value;
template<class T>constexprbool is_lvalue_reference_v =std::is_lvalue_reference<T>::value;
template<class T>constexprbool is_rvalue_reference_v =std::is_rvalue_reference<T>::value;
template<class T>constexprbool is_member_object_pointer_v =std::is_member_object_pointer<T>::value;
template<class T>constexprbool is_member_function_pointer_v =std::is_member_function_pointer<T>::value;
template<class T>constexprbool is_enum_v =std::is_enum<T>::value;
template<class T>constexprbool is_union_v =std::is_union<T>::value;
template<class T>constexprbool is_class_v =std::is_class<T>::value;
template<class T>constexprbool is_function_v =std::is_function<T>::value;
复合类型分类
变量模板
在标头 <experimental/type_traits> 定义
template<class T>constexprbool is_reference_v =std::is_reference<T>::value;
template<class T>constexprbool is_arithmetic_v =std::is_arithmetic<T>::value;
template<class T>constexprbool is_fundamental_v =std::is_fundamental<T>::value;
template<class T>constexprbool is_object_v =std::is_object<T>::value;
template<class T>constexprbool is_scalar_v =std::is_scalar<T>::value;
template<class T>constexprbool is_compound_v =std::is_compound<T>::value;
template<class T>constexprbool is_member_pointer_v =std::is_member_pointer<T>::value;
类型属性
变量模板
在标头 <experimental/type_traits> 定义
template<class T>constexprbool is_const_v =std::is_const<T>::value;
template<class T>constexprbool is_volatile_v =std::is_volatile<T>::value;
template<class T>constexprbool is_trivial_v =std::is_trivial<T>::value;
template<class T>constexprbool is_trivially_copyable_v =std::is_trivially_copyable<T>::value;
template<class T>constexprbool is_standard_layout_v =std::is_standard_layout<T>::value;
template<class T>constexprbool is_pod_v =std::is_pod<T>::value;
template<class T>constexprbool is_literal_type_v =std::is_literal_type<T>::value;
template<class T>constexprbool is_empty_v =std::is_empty<T>::value;
template<class T>constexprbool is_polymorphic_v =std::is_polymorphic<T>::value;
template<class T>constexprbool is_abstract_v =std::is_abstract<T>::value;
template<class T>constexprbool is_final_v =std::is_final<T>::value;
template<class T>constexprbool is_signed_v =std::is_signed<T>::value;
template<class T>constexprbool is_unsigned_v =std::is_unsigned<T>::value;
支持的操作
变量模板
在标头 <experimental/type_traits> 定义
template<class T, class... Args>constexprbool is_constructible_v =std::is_constructible<T, Args...>::value;
template<class T, class... Args>constexprbool is_trivially_constructible_v =std::is_trivially_constructible<T, Args...>::value;
template<class T, class... Args>constexprbool is_nothrow_constructible_v =std::is_nothrow_constructible<T, Args...>::value;
template<class T>constexprbool is_default_constructible_v =std::is_default_constructible<T>::value;
template<class T>constexprbool is_trivially_default_constructible_v =std::is_trivially_default_constructible<T>::value;
template<class T>constexprbool is_nothrow_default_constructible_v =std::is_nothrow_default_constructible<T>::value;
template<class T>constexprbool is_copy_constructible_v =std::is_copy_constructible<T>::value;
template<class T>constexprbool is_trivially_copy_constructible_v =std::is_trivially_copy_constructible<T>::value;
template<class T>constexprbool is_nothrow_copy_constructible_v =std::is_nothrow_copy_constructible<T>::value;
template<class T>constexprbool is_move_constructible_v =std::is_move_constructible<T>::value;
template<class T>constexprbool is_trivially_move_constructible_v =std::is_trivially_move_constructible<T>::value;
template<class T>constexprbool is_nothrow_move_constructible_v =std::is_nothrow_move_constructible<T>::value;
template<class T, class U>constexprbool is_assignable_v =std::is_assignable<T, U>::value;
template<class T, class U>constexprbool is_trivially_assignable_v =std::is_trivially_assignable<T, U>::value;
template<class T, class U>constexprbool is_nothrow_assignable_v =std::is_nothrow_assignable<T, U>::value;
template<class T>constexprbool is_copy_assignable_v =std::is_copy_assignable<T>::value;
template<class T>constexprbool is_trivially_copy_assignable_v =std::is_trivially_copy_assignable<T>::value;
template<class T>constexprbool is_nothrow_copy_assignable_v =std::is_nothrow_copy_assignable<T>::value;
template<class T>constexprbool is_move_assignable_v =std::is_move_assignable<T>::value;
template<class T>constexprbool is_trivially_move_assignable_v =std::is_trivially_move_assignable<T>::value;
template<class T>constexprbool is_nothrow_move_assignable_v =std::is_nothrow_move_assignable<T>::value;
template<class T>constexprbool is_destructible_v =std::is_destructible<T>::value;
template<class T>constexprbool is_trivially_destructible_v =std::is_trivially_destructible<T>::value;
template<class T>constexprbool is_nothrow_destructible_v =std::is_nothrow_destructible<T>::value;
template<class T>constexprbool has_virtual_destructor_v =std::has_virtual_destructor<T>::value;
属性查询
变量模板
在标头 <experimental/type_traits> 定义
template<class T>constexprstd::size_t alignment_of_v =std::alignment_of<T>::value;
template<class T>constexprstd::size_t rank_v =std::rank<T>::value;
template<class T, unsigned I =0>constexprstd::size_t extent_v =std::extent<T, I>::value;
类型关系
变量模板
在标头 <experimental/type_traits> 定义
template<class T, class U>constexprbool is_same_v =std::is_same<T, U>::value;
template<class Base, class Derived>constexprbool is_base_of_v =std::is_base_of<Base, Derived>::value;
template<class From, class To>constexprbool is_convertible_v =std::is_convertible<From, To>::value;

其他变量模板

std::ratio 的比较
变量模板
在标头 <experimental/ratio> 定义
template<class R1, class R2>constexprbool ratio_equal_v =std::ratio_equal<R1, R2>::value;
template<class R1, class R2>constexprbool ratio_not_equal_v =std::ratio_not_equal<R1, R2>::value;
template<class R1, class R2>constexprbool ratio_less_v =std::ratio_less<R1, R2>::value;
template<class R1, class R2>constexprbool ratio_less_equal_v =std::ratio_less_equal<R1, R2>::value;
template<class R1, class R2>constexprbool ratio_greater_v =std::ratio_greater<R1, R2>::value;
template<class R1, class R2>constexprbool ratio_greater_equal_v =std::ratio_greater_equal<R1, R2>::value;
杂项
变量模板
在标头 <experimental/tuple> 定义
template<class T>constexprstd::size_t tuple_size_v =std::tuple_size<T>::value;
在标头 <experimental/chrono> 定义
template<class Rep>constexprbool treat_as_floating_point_v =std::chrono::treat_as_floating_point<Rep>::value;[1]
在标头 <experimental/system_error> 定义
template<class T>constexprbool is_error_code_enum_v =std::is_error_code_enum<T>::value;
template<class T>constexprbool is_error_condition_enum_v =std::is_error_condition_enum<T>::value;
在标头 <experimental/functional> 定义
template<class T>constexprbool is_bind_expression_v =std::is_bind_expression<T>::value;
template<class T>constexprint is_placeholder_v =std::is_placeholder<T>::value;
在标头 <experimental/memory> 定义
template<class T, class Alloc>constexprbool uses_allocator_v =std::uses_allocator<T, Alloc>::value;

[编辑]注解

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

close