Skip to main content

C++ named requirements: UnaryTypeTrait (since C++11)

A UnaryTypeTrait is a class template that describes a property of its template type parameter with an integral_constant (typically bool_constant) specialization.

Requirements

  • DefaultConstructible and CopyConstructible
  • Takes one template type parameter (additional template parameters are optional and allowed)
  • Publicly and unambiguously derived from a specialization of integral_constant, known as its base characteristic
  • The member names of the base characteristic are not hidden and are unambiguously available

Standard library

The following type properties all satisfy UnaryTypeTrait.

  • Primary type categories
  • Composite type categories
  • Type properties
  • Supported operations
  • Property queries

The following standard library class templates also satisfy UnaryTypeTrait.

pubintegral_constant(C++11)compile-time constant of specified type with specified value
pubnegation(C++17)logical NOT metafunction
pubstd::tuple_size<std::tuple>(C++11)obtains the size of tuple at compile time
pubstd::tuple_size<std::array>(C++11)obtains the size of an array
pubstd::tuple_size<std::pair>(C++11)obtains the size of a pair
pubvariant_size
variant_size_v(C++17)
obtains the size of the variant's list of alternatives at compile time
pubis_bind_expression(C++11)indicates that an object is std::bind expression or can be used as one
pubis_placeholder(C++11)indicates that an object is a standard placeholder or can be used as one
pubis_execution_policy(C++17)test whether a class represents an execution policy

C++ named requirements: UnaryTypeTrait (since C++11)

A UnaryTypeTrait is a class template that describes a property of its template type parameter with an integral_constant (typically bool_constant) specialization.

Requirements

  • DefaultConstructible and CopyConstructible
  • Takes one template type parameter (additional template parameters are optional and allowed)
  • Publicly and unambiguously derived from a specialization of integral_constant, known as its base characteristic
  • The member names of the base characteristic are not hidden and are unambiguously available

Standard library

The following type properties all satisfy UnaryTypeTrait.

  • Primary type categories
  • Composite type categories
  • Type properties
  • Supported operations
  • Property queries

The following standard library class templates also satisfy UnaryTypeTrait.

pubintegral_constant(C++11)compile-time constant of specified type with specified value
pubnegation(C++17)logical NOT metafunction
pubstd::tuple_size<std::tuple>(C++11)obtains the size of tuple at compile time
pubstd::tuple_size<std::array>(C++11)obtains the size of an array
pubstd::tuple_size<std::pair>(C++11)obtains the size of a pair
pubvariant_size
variant_size_v(C++17)
obtains the size of the variant's list of alternatives at compile time
pubis_bind_expression(C++11)indicates that an object is std::bind expression or can be used as one
pubis_placeholder(C++11)indicates that an object is a standard placeholder or can be used as one
pubis_execution_policy(C++17)test whether a class represents an execution policy