reflection-inlines.h File
C++ header file with inline implementations for the µTest++ reflection utilities. More...
Included Headers
Namespaces Index
| namespace | micro_os_plus |
|
The primary namespace for the µOS++ framework. More... | |
| namespace | micro_test_plus |
|
Primary namespace for the µTest++ testing framework. More... | |
| namespace | reflection |
|
Reflection utilities for the µTest++ testing framework. More... | |
Functions Index
template <class T> | |
| constexpr std::string_view | type_name (void) |
|
Extract the type name from the __PRETTY_FUNCTION__ macro. More... | |
Description
C++ header file with inline implementations for the µTest++ reflection utilities.
This header provides the inline implementations for the reflection utilities used within the µTest++ framework. It includes the logic for capturing and reporting source location information, such as file names and line numbers, as well as utilities for extracting type names at compile time using compiler-specific macros.
The source_location implementation offers a lightweight, constexpr-compatible alternative to std::source_location, enabling enhanced diagnostics and reporting even in environments lacking C++20 support. The type_name utility leverages compiler intrinsics to obtain human-readable type names for improved test output and debugging.
All definitions reside within the micro_os_plus::micro_test_plus::reflection namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.
The header files are organised within the include/micro-os-plus/micro-test-plus folder to maintain a structured and modular codebase.
This file is intended solely for internal use within the framework and should not be included directly by user code.
Functions
type_name()
| nodiscard constexpr |
Extract the type name from the __PRETTY_FUNCTION__ macro.
This function template parses the compiler-specific __PRETTY_FUNCTION__ macro to extract a concise type name for the template parameter T.
Rather than relying on fixed character offsets (which are fragile across compiler versions and namespace changes), the implementation searches for well-known marker characters in the function signature string:
- Clang formats the signature as "... [T = <typename>]", so the type name lies between the last '[' (skipping "[T = ") and the last ']'.
- GCC formats the signature as "... [with T = <typename>]", so the type name lies between the last '=' (skipping the trailing space) and the last ']'.
This approach is resilient to namespace renaming, namespace nesting changes, and compiler format updates.
- Template Parameters
-
T The type whose name is to be extracted.
- Parameters
None.
- Returns
A std::string_view containing the extracted type name.
Definition at line 145 of file reflection-inlines.h.
Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<.
File Listing
The file content with the documentation metadata removed is:
Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.