namespace std::meta {
consteval string_view display_string_of(info r);
consteval u8string_view u8display_string_of(info r);
}
概要
リフレクションの表示用文字列を取得する。
戻り値
rの人間可読な表示文字列を返す。結果は実装定義である。
備考
std::meta名前空間の関数のうち、戻り値の型がstring_viewまたはu8string_viewであるものは、NULL終端された静的記憶域上の文字列を返す、というルールがある。本関数もそれに該当する。
例
#include <meta>
#include <print>
#include <vector>
int main() {
std::println("{}", std::meta::display_string_of(^^int));
std::println("{}", std::meta::display_string_of(^^std::vector));
}
出力例
int
template<class _Tp, class _Alloc> class std::vector
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: 16 (
-freflectionオプション指定) ✅ - Visual C++: ??
参照
- P2996R13 Reflection for C++26
- LWG Issue 4556. Unclear properties of reflection strings
- C++26で、
string_view/u8string_viewを返すstd::metaの関数がNULL終端された静的記憶域上の文字列を返すことが明確化された
- C++26で、