SpECTRE  v2024.02.05
Type Traits

Namespaces

namespace  cpp20
 C++ STL code present in C++20.
 
namespace  tt
 A collection of useful type traits.
 

Classes

struct  is_any_spin_weighted< T >
 This is a std::true_type if the provided type is a SpinWeighted of any type and spin, otherwise is a std::false_type. More...
 
struct  is_spin_weighted_of< InternalType, T >
 This is a std::true_type if the provided type T is a SpinWeighted of InternalType and any spin, otherwise is a std::false_type. More...
 
struct  is_spin_weighted_of_same_type< T1, T2 >
 This is a std::true_type if the provided type T1 is a SpinWeighted and T2 is a SpinWeighted, and both have the same internal type, but any combination of spin weights. More...
 
struct  tt::is_tensor_index< T >
 Check if a type T is a TensorIndex used in TensorExpressions. More...
 
struct  tt::is_time_index< T >
 Check if a type T is a TensorIndex representing a concrete time index. More...
 
struct  tt::is_tensor_index_type< T >
 Inherits from std::true_type if T is a TensorIndexType. More...
 
struct  get_vector_element_type< T, bool >
 Helper struct to determine the element type of a VectorImpl or container of VectorImpl. More...
 
struct  TypeDisplayer<... >
 Get compiler error with type of template parameter. More...
 
struct  cpp20::remove_cvref< T >
 
struct  tt::can_be_copy_constructed< T, typename >
 Check if T is copy constructible. More...
 
struct  tt::get_fundamental_type< T, typename >
 Extracts the fundamental type for a container. More...
 
struct  tt::has_equivalence< T, typename >
 Check if type T has operator== defined. More...
 
struct  tt::has_inequivalence< T, U >
 Check if type T has operator!= defined. More...
 
class  tt::is_callable< TT, TArgs >
 Check if a type T is callable, i.e. T(Args...) is evaluable. More...
 
struct  tt::is_complex_of_fundamental< T, typename >
 Determines if a type T is a std::complex of a fundamental type, is a std::true_type if so, and otherwise is a std::false_type More...
 
struct  tt::is_integer< I >
 Check if I is an integer type (non-bool, non-character), unlike std::is_integral. More...
 
struct  tt::is_iterable< T, typename >
 Check if type T has a begin() and end() function. More...
 
struct  tt::is_maplike< T, typename >
 Check if type T is like a std::map or std::unordored_map. More...
 
struct  tt::is_std_array< T >
 Check if type T is a std::array. More...
 
struct  tt::is_std_array_of_size< N, T >
 Check if type T is a std::array of a given size. More...
 
struct  tt::is_streamable< S, T, typename >
 Check if type T has operator<<(S, T) defined. More...
 
struct  tt::remove_reference_wrapper< T >
 Gets the underlying type if the type is a std::reference_wrapper, otherwise returns the type itself. More...
 
struct  tt::remove_cvref_wrap< T >
 Removes std::reference_wrapper, references, and cv qualifiers. More...
 

Macros

#define CREATE_GET_STATIC_MEMBER_VARIABLE_OR_DEFAULT(VARIABLE_NAME)
 Generate a metafunction that will retrieve the specified static constexpr member variable, or, if not present, a default. More...
 
#define CREATE_GET_TYPE_ALIAS_OR_DEFAULT(ALIAS_NAME)
 Generate a metafunction that will retrieve the specified type alias, or if not present, assign a default type. More...
 

Typedefs

template<typename T >
using is_derived_of_vector_impl = decltype(detail::is_derived_of_vector_impl_impl(std::declval< T * >()))
 This is std::true_type if the provided type possesses an implicit conversion to any VectorImpl, which is the primary feature of SpECTRE vectors generally. Otherwise, it is std::false_type.
 
template<class T >
using cpp20::remove_cvref_t = typename remove_cvref< T >::type
 
template<typename F >
using tt::function_info = detail::function_info_impl< F >
 Returns a struct that contains the return type, argument types, and the class type if the F is a non-static member function. More...
 

Variables

template<typename T >
constexpr bool tt::is_complex_or_fundamental_v
 Evaluates to true if type T is a std::complex of a fundamental type or if T is a fundamental type. More...
 
template<typename Array >
using tt::array_size = decltype(TypeTraits_detail::array_size_impl(std::declval< const Array & >()))
 Get the size of a std::array as a std::integral_constant. More...
 
template<template< typename... > class U, typename T >
using tt::is_a = detail::wrapped_is_a< detail::is_a_wrapper< U >, T >
 Check if type T is a template specialization of U More...
 
template<template< typename... > class U, typename T >
using tt::is_a_t = typename is_a< U, T >::type
 
template<template< typename... > class U, typename T >
constexpr bool tt::is_a_v = is_a<U, T>::value
 
#define CREATE_HAS_STATIC_MEMBER_VARIABLE(CONSTEXPR_NAME)
 Generate a type trait to check if a class has a static constexpr variable, optionally also checking its type. More...
 
#define CREATE_HAS_STATIC_MEMBER_VARIABLE_V(CONSTEXPR_NAME)
 Generate a type trait to check if a class has a static constexpr variable, optionally also checking its type. More...
 
#define CREATE_HAS_TYPE_ALIAS(ALIAS_NAME)
 Generate a type trait to check if a class has a type alias with a particular name, optionally also checking its type. More...
 
#define CREATE_HAS_TYPE_ALIAS_V(ALIAS_NAME)
 Generate a type trait to check if a class has a type alias with a particular name, optionally also checking its type. More...
 
#define CREATE_IS_CALLABLE(METHOD_NAME)
 Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs... More...
 
#define CREATE_IS_CALLABLE_R_V(METHOD_NAME)
 Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs... More...
 
#define CREATE_IS_CALLABLE_V(METHOD_NAME)
 Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs... More...
 

Detailed Description

A collection of useful type traits, including C++14 and C++17 additions to the standard library.

Macro Definition Documentation

◆ CREATE_GET_STATIC_MEMBER_VARIABLE_OR_DEFAULT

#define CREATE_GET_STATIC_MEMBER_VARIABLE_OR_DEFAULT (   VARIABLE_NAME)
Value:
template <typename CheckingType, auto Default, typename = std::void_t<>> \
struct get_##VARIABLE_NAME##_or_default { \
static constexpr auto value = Default; \
}; \
template <typename CheckingType, auto Default> \
struct get_##VARIABLE_NAME##_or_default< \
CheckingType, Default, \
std::void_t<decltype(CheckingType::VARIABLE_NAME)>> { \
static_assert( \
std::is_same_v<std::decay_t<decltype(Default)>, \
std::decay_t<decltype(CheckingType::VARIABLE_NAME)>>, \
"Types of default and found value are not the same."); \
static constexpr auto value = CheckingType::VARIABLE_NAME; \
}; \
template <typename CheckingType, auto Default> \
constexpr auto get_##VARIABLE_NAME##_or_default_v = \
constexpr T & value(T &t)
Returns t.value() if t is a std::optional otherwise returns t.
Definition: OptionalHelpers.hpp:32

Generate a metafunction that will retrieve the specified static constexpr member variable, or, if not present, a default.

Warning
Please use defaults responsibly. In many cases it is better to require the static member variable is present so the functionality isn't hidden. Also make sure to document the compile-time interface, e.g. with a protocol.

◆ CREATE_GET_TYPE_ALIAS_OR_DEFAULT

#define CREATE_GET_TYPE_ALIAS_OR_DEFAULT (   ALIAS_NAME)
Value:
template <typename CheckingType, typename Default, typename = std::void_t<>> \
struct get_##ALIAS_NAME##_or_default { \
using type = Default; \
}; \
template <typename CheckingType, typename Default> \
struct get_##ALIAS_NAME##_or_default< \
using type = typename CheckingType::ALIAS_NAME; \
}; \
template <typename CheckingType, typename Default> \
using get_##ALIAS_NAME##_or_default_t = \
typename get_##ALIAS_NAME##_or_default<CheckingType, Default>::type;

Generate a metafunction that will retrieve the specified type alias, or if not present, assign a default type.

Warning
Please use defaults responsibly. In many cases it is better to require the type alias is present so the functionality isn't hidden. Also make sure to document the compile-time interface, e.g. with a protocol.

◆ CREATE_HAS_STATIC_MEMBER_VARIABLE

#define CREATE_HAS_STATIC_MEMBER_VARIABLE (   CONSTEXPR_NAME)
Value:
template <typename CheckingType, typename VariableType = NoSuchType*****, \
typename = std::void_t<>> \
struct has_##CONSTEXPR_NAME : std::false_type {}; \
\
template <typename CheckingType, typename VariableType> \
struct has_##CONSTEXPR_NAME<CheckingType, VariableType, \
std::void_t<std::remove_const_t<decltype( \
CheckingType::CONSTEXPR_NAME)>>> \
: std::bool_constant<std::is_same_v<VariableType, NoSuchType*****> or \
std::is_same_v<std::remove_const_t<decltype( \
CheckingType::CONSTEXPR_NAME)>, \
VariableType>> {};
Used to mark "no type" or "bad state" for metaprogramming.
Definition: NoSuchType.hpp:10

Generate a type trait to check if a class has a static constexpr variable, optionally also checking its type.

To generate the corresponding _v metafunction, call CREATE_HAS_STATIC_MEMBER_VARIABLE first and then CREATE_HAS_STATIC_MEMBER_VARIABLE_V.

Example

struct testing_create_has_static_member_variable {
static constexpr size_t foo = 1;
};
static_assert(has_foo_v<testing_create_has_static_member_variable>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(has_foo_v<testing_create_has_static_member_variable, size_t>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(not has_foo_v<testing_create_has_static_member_variable, int>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(not has_foobar_v<testing_create_has_static_member_variable>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(
not has_foobar_v<testing_create_has_static_member_variable, size_t>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
#define CREATE_HAS_STATIC_MEMBER_VARIABLE_V(CONSTEXPR_NAME)
Generate a type trait to check if a class has a static constexpr variable, optionally also checking i...
Definition: CreateHasStaticMemberVariable.hpp:43
#define CREATE_HAS_STATIC_MEMBER_VARIABLE(CONSTEXPR_NAME)
Generate a type trait to check if a class has a static constexpr variable, optionally also checking i...
Definition: CreateHasStaticMemberVariable.hpp:28
See also
CREATE_IS_CALLABLE

◆ CREATE_HAS_STATIC_MEMBER_VARIABLE_V

#define CREATE_HAS_STATIC_MEMBER_VARIABLE_V (   CONSTEXPR_NAME)
Value:
template <typename CheckingType, typename VariableType = NoSuchType*****> \
static constexpr const bool has_##CONSTEXPR_NAME##_v = \

Generate a type trait to check if a class has a static constexpr variable, optionally also checking its type.

To generate the corresponding _v metafunction, call CREATE_HAS_STATIC_MEMBER_VARIABLE first and then CREATE_HAS_STATIC_MEMBER_VARIABLE_V.

Example

struct testing_create_has_static_member_variable {
static constexpr size_t foo = 1;
};
static_assert(has_foo_v<testing_create_has_static_member_variable>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(has_foo_v<testing_create_has_static_member_variable, size_t>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(not has_foo_v<testing_create_has_static_member_variable, int>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(not has_foobar_v<testing_create_has_static_member_variable>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
static_assert(
not has_foobar_v<testing_create_has_static_member_variable, size_t>,
"Failed testing CREATE_HAS_STATIC_MEMBER_VARIABLE");
See also
CREATE_IS_CALLABLE

◆ CREATE_HAS_TYPE_ALIAS

#define CREATE_HAS_TYPE_ALIAS (   ALIAS_NAME)
Value:
template <typename CheckingType, typename AliasType = NoSuchType*****, \
typename = std::void_t<>> \
struct has_##ALIAS_NAME : std::false_type {}; \
\
template <typename CheckingType, typename AliasType> \
struct has_##ALIAS_NAME<CheckingType, AliasType, \
std::void_t<typename CheckingType::ALIAS_NAME>> \
std::is_same_v<AliasType, NoSuchType*****> or \
std::is_same_v<typename CheckingType::ALIAS_NAME, AliasType>> {};

Generate a type trait to check if a class has a type alias with a particular name, optionally also checking its type.

To generate the corresponding _v metafunction, call CREATE_HAS_TYPE_ALIAS first and then CREATE_HAS_TYPE_ALIAS_V.

Example

CREATE_HAS_TYPE_ALIAS(foobar_alias)
struct testing_create_has_type_alias {
using foo_alias = int;
};
static_assert(has_foo_alias_v<testing_create_has_type_alias>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(has_foo_alias_v<testing_create_has_type_alias, int>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foo_alias_v<testing_create_has_type_alias, double>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foobar_alias_v<testing_create_has_type_alias>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foobar_alias_v<testing_create_has_type_alias, int>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
#define CREATE_HAS_TYPE_ALIAS_V(ALIAS_NAME)
Generate a type trait to check if a class has a type alias with a particular name,...
Definition: CreateHasTypeAlias.hpp:39
#define CREATE_HAS_TYPE_ALIAS(ALIAS_NAME)
Generate a type trait to check if a class has a type alias with a particular name,...
Definition: CreateHasTypeAlias.hpp:27
See also
CREATE_IS_CALLABLE

◆ CREATE_HAS_TYPE_ALIAS_V

#define CREATE_HAS_TYPE_ALIAS_V (   ALIAS_NAME)
Value:
template <typename CheckingType, typename AliasType = NoSuchType*****> \
static constexpr const bool has_##ALIAS_NAME##_v = \

Generate a type trait to check if a class has a type alias with a particular name, optionally also checking its type.

To generate the corresponding _v metafunction, call CREATE_HAS_TYPE_ALIAS first and then CREATE_HAS_TYPE_ALIAS_V.

Example

CREATE_HAS_TYPE_ALIAS(foobar_alias)
struct testing_create_has_type_alias {
using foo_alias = int;
};
static_assert(has_foo_alias_v<testing_create_has_type_alias>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(has_foo_alias_v<testing_create_has_type_alias, int>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foo_alias_v<testing_create_has_type_alias, double>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foobar_alias_v<testing_create_has_type_alias>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
static_assert(not has_foobar_alias_v<testing_create_has_type_alias, int>,
"Failed testing CREATE_HAS_TYPE_ALIAS");
See also
CREATE_IS_CALLABLE

◆ CREATE_IS_CALLABLE

#define CREATE_IS_CALLABLE (   METHOD_NAME)
Value:
struct AnyReturnType##METHOD_NAME {}; \
\
template <typename ReturnType, typename TT, typename... TArgs> \
class is_##METHOD_NAME##_callable_r { \
private: \
struct NotCallable {}; \
template <typename T, typename... Args> \
static auto test_callable(int) \
-> decltype(std::declval<T>().METHOD_NAME(std::declval<Args>()...)); \
template <typename, typename...> \
static auto test_callable(...) -> NotCallable; \
\
public: \
static constexpr bool value = \
(std::is_same_v<ReturnType, AnyReturnType##METHOD_NAME> and \
not std::is_same_v<decltype(test_callable<TT, TArgs...>(0)), \
NotCallable>) or \
std::is_same_v<decltype(test_callable<TT, TArgs...>(0)), ReturnType>; \
}; \
template <typename ReturnType, typename T, typename... Args> \
using is_##METHOD_NAME##_callable_r_t = \
typename is_##METHOD_NAME##_callable_r<ReturnType, T, Args...>::type; \
template <typename TT, typename... TArgs> \
using is_##METHOD_NAME##_callable = \
is_##METHOD_NAME##_callable_r<AnyReturnType##METHOD_NAME, TT, TArgs...>; \
template <typename TT, typename... TArgs> \
using is_##METHOD_NAME##_callable_t = \
is_##METHOD_NAME##_callable_r_t<AnyReturnType##METHOD_NAME, TT, \
TArgs...>;

Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs...

The usage of the type trait is identical to the usage of the tt::is_callable type trait. The name of the type trait is is_METHOD_NAME_callable and is not placed in the tt namespace. To avoid collisions it is highly recommended that type traits generated with this macro are generated into _detail namespaces. This will reduce redefinition compilation errors.

Note that variable templates with _r and _t suffixes that follow the standard library's naming convention are also generated. To generate corresponding _v metafunctions, call CREATE_IS_CALLABLE first and then CREATE_IS_CALLABLE_V and/or CREATE_IS_CALLABLE_R_V.

Example

struct bar {
size_t foo(int /*unused*/, double /*unused*/) { return size_t{0}; }
};
static_assert(is_foo_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(is_foo_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar, int>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar>, "Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_r_v<int, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
#define CREATE_IS_CALLABLE_R_V(METHOD_NAME)
Generate a type trait to check if a class has a member function that can be invoked with arguments of...
Definition: CreateIsCallable.hpp:64
#define CREATE_IS_CALLABLE_V(METHOD_NAME)
Generate a type trait to check if a class has a member function that can be invoked with arguments of...
Definition: CreateIsCallable.hpp:68
#define CREATE_IS_CALLABLE(METHOD_NAME)
Generate a type trait to check if a class has a member function that can be invoked with arguments of...
Definition: CreateIsCallable.hpp:31
See also
tt::is_callable

◆ CREATE_IS_CALLABLE_R_V

#define CREATE_IS_CALLABLE_R_V (   METHOD_NAME)
Value:
template <typename ReturnType, typename T, typename... Args> \
constexpr bool is_##METHOD_NAME##_callable_r_v = \
is_##METHOD_NAME##_callable_r<ReturnType, T, Args...>::value;

Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs...

The usage of the type trait is identical to the usage of the tt::is_callable type trait. The name of the type trait is is_METHOD_NAME_callable and is not placed in the tt namespace. To avoid collisions it is highly recommended that type traits generated with this macro are generated into _detail namespaces. This will reduce redefinition compilation errors.

Note that variable templates with _r and _t suffixes that follow the standard library's naming convention are also generated. To generate corresponding _v metafunctions, call CREATE_IS_CALLABLE first and then CREATE_IS_CALLABLE_V and/or CREATE_IS_CALLABLE_R_V.

Example

struct bar {
size_t foo(int /*unused*/, double /*unused*/) { return size_t{0}; }
};
static_assert(is_foo_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(is_foo_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar, int>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar>, "Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_r_v<int, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
See also
tt::is_callable

◆ CREATE_IS_CALLABLE_V

#define CREATE_IS_CALLABLE_V (   METHOD_NAME)
Value:
template <typename T, typename... Args> \
constexpr bool is_##METHOD_NAME##_callable_v = \
is_##METHOD_NAME##_callable<T, Args...>::value;

Generate a type trait to check if a class has a member function that can be invoked with arguments of type TArgs...

The usage of the type trait is identical to the usage of the tt::is_callable type trait. The name of the type trait is is_METHOD_NAME_callable and is not placed in the tt namespace. To avoid collisions it is highly recommended that type traits generated with this macro are generated into _detail namespaces. This will reduce redefinition compilation errors.

Note that variable templates with _r and _t suffixes that follow the standard library's naming convention are also generated. To generate corresponding _v metafunctions, call CREATE_IS_CALLABLE first and then CREATE_IS_CALLABLE_V and/or CREATE_IS_CALLABLE_R_V.

Example

struct bar {
size_t foo(int /*unused*/, double /*unused*/) { return size_t{0}; }
};
static_assert(is_foo_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(is_foo_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar, int>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_v<bar>, "Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_r_v<size_t, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foo_callable_r_v<int, bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
static_assert(not is_foobar_callable_v<bar, int, double>,
"Failed testing CREATE_IS_CALLABLE");
See also
tt::is_callable

Typedef Documentation

◆ array_size

template<typename Array >
using tt::array_size = typedef decltype(TypeTraits_detail::array_size_impl(std::declval<const Array&>()))

Get the size of a std::array as a std::integral_constant.

Details

Given a std::array, Array, returns a std::integral_constant that has the size of the array as its value

Usage

For a std::array T

using result = tt::array_size<T>;
decltype(TypeTraits_detail::array_size_impl(std::declval< const Array & >())) array_size
Get the size of a std::array as a std::integral_constant.
Definition: ArraySize.hpp:46

Returns: std::integral_constant<std::size_t>

Semantics: For a type T,

Example

"Failed testing type trait array_size");
"Failed testing type trait array_size");
Template Parameters
Arraythe whose size should be stored in value of array_size

◆ function_info

template<typename F >
using tt::function_info = typedef detail::function_info_impl<F>

Returns a struct that contains the return type, argument types, and the class type if the F is a non-static member function.

The return class has member type aliases:

  • return_type The return type of the function
  • argument_types A tmpl::list of the arguments types of the function
  • class_type The type of the class if the function is a non-static member function, otherwise void
Note
For static member variables the class will be void because they are effectively free functions.

◆ is_a

template<template< typename... > class U, typename T >
using tt::is_a = typedef detail::wrapped_is_a<detail::is_a_wrapper<U>, T>

Check if type T is a template specialization of U

Requires: U is a class template

Effects: If T is a template specialization of U, then inherits from std::true_type, otherwise inherits from std::false_type

Usage

For any type T and class template U

using result = tt::is_a<U, T>;
detail::wrapped_is_a< detail::is_a_wrapper< U >, T > is_a
Check if type T is a template specialization of U
Definition: IsA.hpp:58

Returns: std::bool_constant

Semantics: If the type T is a template specialization of the type U, then

typename result::type = std::true_type;

otherwise

typename result::type = std::false_type;

Example

"Failed testing type trait is_a<vector>");
"Failed testing type trait is_a<vector>");
static_assert(tt::is_a_v<std::vector, std::vector<D>>,
"Failed testing type trait is_a<vector>");
"Failed testing type trait is_a<deque>");
"Failed testing type trait is_a<deque>");
"Failed testing type trait is_a<deque>");
"Failed testing type trait is_a<forward_list>");
"Failed testing type trait is_a<forward_list>");
"Failed testing type trait is_a<forward_list>");
"Failed testing type trait is_a<list>");
"Failed testing type trait is_a<list>");
"Failed testing type trait is_a<list>");
"Failed testing type trait is_a<map>");
"Failed testing type trait is_a<map>");
"Failed testing type trait is_a<map>");
"Failed testing type trait is_a<unordered_map>");
"Failed testing type trait is_a<unordered_map>");
static_assert(
"Failed testing type trait is_a<unordered_map>");
"Failed testing type trait is_a<set>");
"Failed testing type trait is_a<set>");
"Failed testing type trait is_a<set>");
"Failed testing type trait is_a<unordered_set>");
"Failed testing type trait is_a<unordered_set>");
"Failed testing type trait is_a<unordered_set>");
"Failed testing type trait is_a<multiset>");
"Failed testing type trait is_a<multiset>");
"Failed testing type trait is_a<multiset>");
static_assert(
"Failed testing type trait is_a<unordered_multiset>");
"Failed testing type trait is_a<unordered_multiset>");
static_assert(
"Failed testing type trait is_a<unordered_multiset>");
static_assert(
"Failed testing type trait is_a<multimap>");
"Failed testing type trait is_a<multimap>");
"Failed testing type trait is_a<multimap>");
"Failed testing type trait is_a<unordered_multimap>");
"Failed testing type trait is_a<unordered_multimap>");
"Failed testing type trait is_a<unordered_multimap>");
"Failed testing type trait is_a<priority_queue>");
"Failed testing type trait is_a<priority_queue>");
"Failed testing type trait is_a<priority_queue>");
"Failed testing type trait is_a<queue>");
"Failed testing type trait is_a<queue>");
"Failed testing type trait is_a<queue>");
"Failed testing type trait is_a<stack>");
"Failed testing type trait is_a<stack>");
"Failed testing type trait is_a<stack>");
"Failed testing type trait is_a<unique_ptr>");
"Failed testing type trait is_a<unique_ptr>");
"Failed testing type trait is_a<unique_ptr>");
"Failed testing type trait is_a<unique_ptr>");
"Failed testing type trait is_a<shared_ptr>");
"Failed testing type trait is_a<shared_ptr>");
"Failed testing type trait is_a<shared_ptr>");
"Failed testing type trait is_a<shared_ptr>");
"Failed testing type trait is_a<weak_ptr>");
"Failed testing type trait is_a<weak_ptr>");
"Failed testing type trait is_a<weak_ptr>");
"Failed testing type trait is_a<weak_ptr>");
"Failed testing type trait is_a");
"Failed testing type trait is_a");
"Failed testing type trait is_a<future>");
"Failed testing type trait is_a<future>");
"Failed testing type trait is_a<future>");
"Failed testing type trait is_a<shared_future>");
"Failed testing type trait is_a<shared_future>");
"Failed testing type trait is_a<shared_future>");
typename is_a< U, T >::type is_a_t
Definition: IsA.hpp:66
See also
is_std_array
Template Parameters
Ttype to check
Uthe type that T might be a template specialization of

◆ is_a_t

template<template< typename... > class U, typename T >
using tt::is_a_t = typedef typename is_a<U, T>::type
See also
is_a

Variable Documentation

◆ is_a_v

template<template< typename... > class U, typename T >
constexpr bool tt::is_a_v = is_a<U, T>::value
constexpr
See also
is_a

◆ is_complex_or_fundamental_v

template<typename T >
constexpr bool tt::is_complex_or_fundamental_v
constexpr
Initial value:
=
is_complex_of_fundamental_v<T> or std::is_fundamental_v<T>

Evaluates to true if type T is a std::complex of a fundamental type or if T is a fundamental type.