Skip to main content

The type_traits Namespace Reference

Type trait utilities and metaprogramming support for the µTest++ testing framework. More...

Definition

namespace micro_os_plus::micro_test_plus::type_traits { ... }

Classes Index

structfloating_point_constant<T, N, D, Size, P>

Struct template representing a generic floating point constant with custom size and precision. More...

structfunction_traits<R(*)(Args_T...)>

Struct template specialisation for extracting function traits from function pointer types. More...

structfunction_traits<R(Args_T...)>

Struct template specialisation for extracting function traits from plain function types. More...

structfunction_traits<R(T::*)(Args_T...) const>

Struct template specialisation for extracting function traits from const member function types. More...

structfunction_traits<R(T::*)(Args_T...)>

Struct template specialisation for extracting function traits from non-const member function types. More...

structgenuine_integral_value<T>

Struct template representing a genuine integral value. More...

structidentity<T, class...>

Struct template for compile-time type identity. More...

structintegral_constant<N>

Struct template representing a generic integral constant. More...

structlist<class...>

Struct template representing a compile-time type list. More...

structop

Empty base struct for all operator types. More...

structrequires_<bool>

Struct template for SFINAE requirements. More...

structrequires_<true>

Specialisation of the requirements struct template for true. More...

structvalue<T, class>

Struct template representing a generic value, accessible via a getter. More...

structvalue<T, type_traits::requires_t< type_traits::is_floating_point_v< T > >>

Struct template representing a floating point value with precision control. More...

Typedefs Index

template <bool Cond>
usingrequires_t = typename requires_< Cond >::type

Alias template for extracting the type member from requires_. More...

Functions Index

template <class T>
T &&declval (void)

Utility function template to simulate std::declval for type deduction. More...

template <class...>
constexpr autois_convertible (...)

Fallback function template for is_convertible, returns false if the conversion is not valid. More...

template <class From, class To>
constexpr auto is_convertible (int n) -> decltype(bool(To(declval< From >())))

Function template to determine if one type is convertible to another. More...

template <class...>
constexpr boolis_valid (...)

Fallback function template for is_valid, returns false if the expression is not valid. More...

template <class... Ts, class Expr_T>
constexpr auto is_valid (Expr_T expr) -> decltype(expr(declval< Ts... >()), bool())

Variables Index

template <class T>
static constexpr autohas_epsilon_v = is_valid<T> ([] (auto t) -> decltype (void (t.epsilon)) {})

Variable template to determine if a type provides an epsilon member. More...

template <class T>
static constexpr autohas_npos_v = is_valid<T> ([] (auto t) -> decltype (void (t.npos)) {})

Variable template to determine if a type provides a static npos member. More...

template <class T>
static constexpr autohas_value_v = is_valid<T> ([] (auto t) -> decltype (void (t.value)) {})

Variable template to determine if a type provides a value member. More...

template <class T>
static constexpr autois_container_v = ...

Variable template to determine if a type models a container. More...

template <class From, class To>
constexpr autois_convertible_v = is_convertible<From, To> (0)

Variable template to determine if one type is convertible to another. More...

template <class T>
constexpr autois_floating_point_v = false

Variable template to determine if a type is a floating point type. More...

constexpr autois_floating_point_v< double > = true

Variable template specialisation indicating that double is a floating point type. More...

constexpr autois_floating_point_v< float > = true

Variable template specialisation indicating that float is a floating point type. More...

constexpr autois_floating_point_v< long double > = true

Variable template specialisation indicating that long double is a floating point type. More...

template <class T>
constexpr autois_op_v = __is_base_of (type_traits::op, T)

Variable template to determine if a type derives from op. More...

Description

Type trait utilities and metaprogramming support for the µTest++ testing framework.

The type_traits namespace offers a comprehensive suite of type trait templates and metaprogramming utilities employed throughout the µTest++ framework.

This includes templates for function traits, type lists, identity, value wrappers, and compile-time checks for container types, floating point types, and type convertibility. It also provides generic integral and floating point constant wrappers, as well as mechanisms for SFINAE and requirements checking.

These utilities facilitate advanced template programming, type deduction, and compile-time introspection, supporting the flexible and type-safe design of the framework.

All definitions within this namespace are implemented in the include/micro-os-plus folder to maintain a structured and modular codebase.

Typedefs

requires_t

template <bool Cond>
using micro_os_plus::micro_test_plus::type_traits::requires_t = typename requires_<Cond>::type

Alias template for extracting the type member from requires_.

Template Parameters
Cond

The boolean condition to be checked at compile time.

The requires_t alias template simplifies the use of the requires_ struct template by directly exposing the nested type member. It is commonly used to enforce compile-time requirements in template declarations.

Definition at line 662 of file type-traits.h.

Functions

declval()

template <class T>
T && micro_os_plus::micro_test_plus::type_traits::declval (void)

Utility function template to simulate std::declval for type deduction.

Template Parameters
T

The type for which an rvalue reference is required.

Parameters

None.

Returns

An rvalue reference to type T.

The declval function template provides a mechanism for obtaining an rvalue reference to a type T without requiring an actual object. This is primarily used in unevaluated contexts, such as within decltype, to deduce types during template metaprogramming in the µTest++ framework.

Definition at line 335 of file type-traits.h.

Referenced by is_convertible and is_valid.

is_convertible()

template <class...>
auto micro_os_plus::micro_test_plus::type_traits::is_convertible (...)
constexpr

Fallback function template for is_convertible, returns false if the conversion is not valid.

Template Parameters
...Unused

Unused template parameters.

Return Values
false

indicating the conversion is not valid.

This overload is selected when the primary is_convertible template cannot be instantiated, providing a false result for invalid conversions.

Definition at line 582 of file type-traits.h.

583 {
584 return false;
585 }

is_convertible()

template <class From, class To>
decltype(bool(To(declval< From >()))) micro_os_plus::micro_test_plus::type_traits::is_convertible (int n)
constexpr

Function template to determine if one type is convertible to another.

Template Parameters
From

The source type to be checked for convertibility.

To

The target type to which conversion is tested.

Parameters
n

Dummy parameter used for overload resolution.

Return Values
true

if From is convertible to To.

The is_convertible function template checks, at compile time, whether a value of type From can be implicitly converted to type To. This is achieved using SFINAE and is primarily used as an implementation detail for the is_convertible_v variable template within the µTest++ framework.

If the conversion is valid, this overload is selected and returns true.

Definition at line 561 of file type-traits.h.

561 is_convertible (int n) -> decltype (bool (To (declval<From> ())))
562 {
563 (void)n; // Prevent the unused parameter warning.
564 return true;
565 }

Reference declval.

is_valid()

template <class...>
bool micro_os_plus::micro_test_plus::type_traits::is_valid (...)
constexpr

Fallback function template for is_valid, returns false if the expression is not valid.

Template Parameters
...Ts

The argument types to be tested.

Returns

false indicating the expression is not valid for the given argument types.

This overload is selected when the primary is_valid template cannot be instantiated, providing a false result for invalid expressions.

Definition at line 358 of file type-traits.h.

358 is_valid (...) -> bool
359 {
360 return false;
361 }

is_valid()

template <class... Ts, class Expr_T>
decltype(expr(declval< Ts... >()), bool()) micro_os_plus::micro_test_plus::type_traits::is_valid (Expr_T expr)
constexpr

Definition at line 338 of file type-traits.h.

338 is_valid (Expr_T expr) -> decltype (expr (declval<Ts...> ()), bool ())
339 {
340 return true;
341 }

Reference declval.

Variables

has_epsilon_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::has_epsilon_v = is_valid<T> ([] (auto t) -> decltype (void (t.epsilon)) {})
constexpr static

Variable template to determine if a type provides an epsilon member.

Template Parameters
T

The type to be checked for the presence of an epsilon member.

Return Values
true

if T has a member named epsilon.

false

otherwise.

The has_epsilon_v variable template evaluates to true if the given type T defines a member named epsilon. This trait is determined at compile time using SFINAE and the is_valid utility, and is used throughout the µTest++ framework to enable generic handling of types that represent floating-point values or require precision control.

Definition at line 442 of file type-traits.h.

443 = is_valid<T> ([] (auto t) -> decltype (void (t.epsilon)) {});

has_npos_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::has_npos_v = is_valid<T> ([] (auto t) -> decltype (void (t.npos)) {})
constexpr static

Variable template to determine if a type provides a static npos member.

Template Parameters
T

The type to be checked for the presence of a static npos member.

Return Values
true

if T has a static member named npos.

false

otherwise.

The has_npos_v variable template evaluates to true if the given type T defines a static member named npos. This trait is determined at compile time using SFINAE and the is_valid utility, and is used throughout the µTest++ framework to enable generic handling of types that follow the standard string or container conventions.

Definition at line 401 of file type-traits.h.

402 = is_valid<T> ([] (auto t) -> decltype (void (t.npos)) {});

Referenced by micro_os_plus::micro_test_plus::test_reporter::operator<<.

has_value_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::has_value_v = is_valid<T> ([] (auto t) -> decltype (void (t.value)) {})
constexpr static

Variable template to determine if a type provides a value member.

Template Parameters
T

The type to be checked for the presence of a value member.

Return Values
true

if T has a member named value.

false

otherwise.

The has_value_v variable template evaluates to true if the given type T defines a member named value. This trait is determined at compile time using SFINAE and the is_valid utility, and is used throughout the µTest++ framework to enable generic handling of types that encapsulate a value, such as wrappers or constant types.

Definition at line 421 of file type-traits.h.

422 = is_valid<T> ([] (auto t) -> decltype (void (t.value)) {});

is_container_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::is_container_v
constexpr static

Variable template to determine if a type models a container.

Initialiser
= is_valid<T> ( [] (auto t) -> decltype (t.begin (), t.end (), void ()) {})
Template Parameters
T

The type to be checked for container-like behaviour.

Return Values
true

if T has both begin() and end() member functions.

false

otherwise.

The is_container_v variable template evaluates to true if the given type T provides both begin() and end() member functions, indicating that it models a standard container concept. This trait is determined at compile time using SFINAE and is_valid, and is used throughout the µTest++ framework to enable generic handling of container types in template metaprogramming.

Definition at line 380 of file type-traits.h.

380 static constexpr auto is_container_v = is_valid<T> (

is_convertible_v

template <class From, class To>
auto micro_os_plus::micro_test_plus::type_traits::is_convertible_v = is_convertible<From, To> (0)
constexpr

Variable template to determine if one type is convertible to another.

Template Parameters
From

The source type to be checked for convertibility.

To

The target type to which conversion is tested.

Return Values
true

if From is convertible to To.

false

otherwise.

The is_convertible_v variable template evaluates to true if the type From is implicitly convertible to the type To, and false otherwise. This trait is determined at compile time and is used throughout the µTest++ framework to enable type-safe conversions and requirements checking in template metaprogramming.

Definition at line 605 of file type-traits.h.

is_floating_point_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::is_floating_point_v = false
constexpr

Variable template to determine if a type is a floating point type.

Template Parameters
T

The type to be checked for floating point classification.

Return Values
true

if T is a floating point type.

false

otherwise.

The is_floating_point_v variable template evaluates to true if the given type T is a floating point type (float, double, or long double). For all other types, it evaluates to false. This trait is used throughout the µTest++ framework to enable type-safe handling and specialisation for floating point types in template metaprogramming.

Specialisations are provided for float, double, and long double, each evaluating to true.

Definition at line 465 of file type-traits.h.

465 inline constexpr auto is_floating_point_v = false;

is_floating_point_v< double >

auto micro_os_plus::micro_test_plus::type_traits::is_floating_point_v< double > = true
constexpr

Variable template specialisation indicating that double is a floating point type.

This specialisation of the is_floating_point_v variable template evaluates to true for the double type, confirming that it is recognised as a floating point type within the µTest++ framework. This enables type-safe handling and specialisation for floating point types in template metaprogramming.

See Also

is_floating_point_v

Definition at line 497 of file type-traits.h.

497 inline constexpr auto is_floating_point_v<double> = true;

is_floating_point_v< float >

auto micro_os_plus::micro_test_plus::type_traits::is_floating_point_v< float > = true
constexpr

Variable template specialisation indicating that float is a floating point type.

This specialisation of the is_floating_point_v variable template evaluates to true for the float type, confirming that it is recognised as a floating point type within the µTest++ framework. This enables type-safe handling and specialisation for floating point types in template metaprogramming.

See Also

is_floating_point_v

Definition at line 481 of file type-traits.h.

481 inline constexpr auto is_floating_point_v<float> = true;

is_floating_point_v< long double >

auto micro_os_plus::micro_test_plus::type_traits::is_floating_point_v< long double > = true
constexpr

Variable template specialisation indicating that long double is a floating point type.

This specialisation of the is_floating_point_v variable template evaluates to true for the long double type, confirming that it is recognised as a floating point type within the µTest++ framework. This enables type-safe handling and specialisation for floating point types in template metaprogramming.

See Also

is_floating_point_v

Definition at line 513 of file type-traits.h.

513 inline constexpr auto is_floating_point_v<long double> = true;

is_op_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::is_op_v = __is_base_of (type_traits::op, T)
constexpr

Variable template to determine if a type derives from op.

Template Parameters
T

The type to be checked for derivation from op.

Return Values
true

if T is derived from type_traits::op.

false

otherwise.

The is_op_v variable template evaluates to true if the given type T is derived from the type_traits::op base struct, and false otherwise. This trait is determined at compile time using compiler intrinsics and is used throughout the µTest++ framework to enable generic handling and detection of operator-like or value wrapper types in template metaprogramming.

Definition at line 946 of file type-traits.h.

946 inline constexpr auto is_op_v = __is_base_of (type_traits::op, T);

Referenced by micro_os_plus::micro_test_plus::test_reporter::fail.


The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus by Doxygen 1.14.0.