std::meta::display_string_of, std::meta::u8display_string_of
From cppreference.com
| Defined in header <meta>
|
||
consteval std::string_view display_string_of( std::meta::info r );
|
(1) | (since C++26) |
consteval std::u8string_view u8display_string_of( std::meta::info r );
|
(2) | (since C++26) |
Returns an implementation-defined string. Implementations are encouraged to produce text that is helpful in identifying what r represents.
Parameters
| r | - | a reflection value |
Return value
An implementation-defined string. Where possible, the string should be suitable for identifying the represented construct.
Notes
The result V is null-terminated: V.data()[V.size()] is guaranteed to be '\0'. Each element in V is a potentially non-unique object with static storage duration that is usable in constant expressions; a pointer to such an element is not suitable for use as a template argument for a non-type template parameter of pointer type.
Example
Run this code
#include <initializer_list>
#include <iostream>
#include <meta>
#include <vector>
struct S { int m; };
enum class E { e };
void foo() noexcept;
int main()
{
template for
(
static constexpr auto reflections =
{
^^S, ^^S::m, ^^E, ^^E::e, ^^foo, ^^std, ^^std::vector<int>
};
constexpr auto reflection : reflections
)
std::cout << display_string_of(reflection) << '\n';
}
Possible output:
S
S::m
E
E::e
void foo()
std
std::vector<int>
