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
struct | floating_point_constant<T, N, D, Size, P> |
Struct template representing a generic floating point constant with custom size and precision. More... | |
struct | function_traits<R(*)(Args_T...)> |
Struct template specialisation for extracting function traits from function pointer types. More... | |
struct | function_traits<R(Args_T...)> |
Struct template specialisation for extracting function traits from plain function types. More... | |
struct | function_traits<R(T::*)(Args_T...) const> |
Struct template specialisation for extracting function traits from const member function types. More... | |
struct | function_traits<R(T::*)(Args_T...)> |
Struct template specialisation for extracting function traits from non-const member function types. More... | |
struct | genuine_integral_value<T> |
Struct template representing a genuine integral value. More... | |
struct | identity<T, class...> |
Struct template for compile-time type identity. More... | |
struct | integral_constant<N> |
Struct template representing a generic integral constant. More... | |
struct | list<class...> |
Struct template representing a compile-time type list. More... | |
struct | op |
Empty base struct for all operator types. More... | |
struct | requires_<bool> |
Struct template for SFINAE requirements. More... | |
struct | requires_<true> |
Specialisation of the requirements struct template for | |
struct | value<T, class> |
Struct template representing a generic value, accessible via a getter. More... | |
struct | value<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
using | requires_t = typename requires_< Cond >::type |
Alias template for extracting the | |
Variables Index
auto | has_epsilon_v = is_valid<T> ([] (auto t) -> decltype (void (t.epsilon)) {}) |
Variable template to determine if a type provides an | |
auto | has_npos_v = is_valid<T> ([] (auto t) -> decltype (void (t.npos)) {}) |
Variable template to determine if a type provides a static | |
auto | has_value_v = is_valid<T> ([] (auto t) -> decltype (void (t.value)) {}) |
Variable template to determine if a type provides a | |
auto | is_container_v = is_valid<T> ( [] (auto t) -> decltype (t.begin (), t.end (), void ()) {}) |
Variable template to determine if a type models a container. More... | |
auto | is_convertible_v = is_convertible<From, To> (0) |
Variable template to determine if one type is convertible to another. More... | |
auto | is_floating_point_v = false |
Variable template to determine if a type is a floating point type. More... | |
auto | is_floating_point_v< double > = true |
Variable template specialisation indicating that | |
auto | is_floating_point_v< float > = true |
Variable template specialisation indicating that | |
auto | is_floating_point_v< long double > = true |
Variable template specialisation indicating that | |
auto | is_op_v = __is_base_of (type_traits::op, T) |
Variable template to determine if a type derives from | |
Functions Index
T && | declval (void) |
Utility function template to simulate std::declval for type deduction. More... | |
constexpr auto | is_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 bool | is_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
|
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.
Variables
has_epsilon_v
| constexprstatic |
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 namedepsilon
.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.
has_npos_v
| constexprstatic |
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 namednpos
.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.
has_value_v
| constexprstatic |
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 namedvalue
.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.
is_container_v
| constexprstatic |
Variable template to determine if a type models a container.
- Template Parameters
T The type to be checked for container-like behaviour.
- Return Values
true if T
has bothbegin()
andend()
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.
is_convertible_v
| 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 toTo
.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
| 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.
is_floating_point_v< double >
| 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 >
| 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 >
| 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
| 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 fromtype_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.
Functions
declval()
|
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.
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.
is_convertible()
| 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 toTo
.
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()
| 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.
is_valid()
| 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.