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

usingrequires_t = typename requires_< Cond >::type

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

Variables Index

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

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

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...

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

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

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

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

autois_convertible_v = is_convertible<From, To> (0)

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

autois_floating_point_v = false

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

autois_floating_point_v< double > = true

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

autois_floating_point_v< float > = true

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

autois_floating_point_v< long double > = true

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

autois_op_v = __is_base_of (type_traits::op, T)

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

Functions Index

T &&declval (void)

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

constexpr autois_convertible (...)

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

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

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

constexpr boolis_valid (...)

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

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

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
CondThe 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.

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)) {})
constexprstatic

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

Template Parameters
TThe type to be checked for the presence of an epsilon member.
Return Values
trueif T has a member named epsilon.
falseotherwise.

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.

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)) {})
constexprstatic

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

Template Parameters
TThe type to be checked for the presence of a static npos member.
Return Values
trueif T has a static member named npos.
falseotherwise.

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.

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)) {})
constexprstatic

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

Template Parameters
TThe type to be checked for the presence of a value member.
Return Values
trueif T has a member named value.
falseotherwise.

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.

is_container_v

template <class T>
auto micro_os_plus::micro_test_plus::type_traits::is_container_v = is_valid<T> ( [] (auto t) -> decltype (t.begin (), t.end (), void ()) {})
constexprstatic

Variable template to determine if a type models a container.

Template Parameters
TThe type to be checked for container-like behaviour.
Return Values
trueif T has both begin() and end() member functions.
falseotherwise.

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.

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
FromThe source type to be checked for convertibility.
ToThe target type to which conversion is tested.
Return Values
trueif From is convertible to To.
falseotherwise.

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
TThe type to be checked for floating point classification.
Return Values
trueif T is a floating point type.
falseotherwise.

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.

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.

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.

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.

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
TThe type to be checked for derivation from op.
Return Values
trueif T is derived from type_traits::op.
falseotherwise.

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.

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
TThe 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.

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
...UnusedUnused template parameters.
Return Values
falseindicating 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.

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
FromThe source type to be checked for convertibility.
ToThe target type to which conversion is tested.
Parameters
nDummy parameter used for overload resolution.
Return Values
trueif 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.

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
...TsThe 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.

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.


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


Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.