diff --git a/.github/workflows/script/ngword_check.py b/.github/workflows/script/ngword_check.py index db7f480aa1..4c395f7be7 100644 --- a/.github/workflows/script/ngword_check.py +++ b/.github/workflows/script/ngword_check.py @@ -50,6 +50,7 @@ ("", "voaltile", "volatile"), ("", "Updated upstream", ""), ("", "Stashed changes", ""), + ("", "アラインメント", "アライメント"), ("", "イテレーター", "イテレータ"), ("", "子ルーチン", "コルーチン"), ("", "移譲", "委譲"), diff --git a/GLOBAL_DEFINED_WORDS.json b/GLOBAL_DEFINED_WORDS.json index 616cfd9293..19ddb2520f 100644 --- a/GLOBAL_DEFINED_WORDS.json +++ b/GLOBAL_DEFINED_WORDS.json @@ -209,5 +209,17 @@ "ダングリング": { "yomi": "だんぐりんぐ", "desc": "dangling。寿命が尽きた無効なオブジェクトやメモリ領域を、ポインタ・参照・イテレータなどが指し続けている状態のこと。これらにアクセスすると未定義の動作を引き起こす" + }, + "構造的型": { + "yomi": "こうぞうてきかた", + "desc": "structural type。定数テンプレートパラメータとして使用できる型の条件。スカラ型、左辺値参照型、すべての基底クラスと非静的データメンバがpublicかつmutableでなく構造的型であるリテラルクラス型、および同様の条件を満たす配列型が該当する" + }, + "定数テンプレートパラメータ": { + "yomi": "ていすうてんぷれーとぱらめーた", + "desc": "constant template parameter。テンプレートパラメータのうち、型ではなく値をとるもの。C++23以前は「非型テンプレートパラメータ (non-type template parameter)」と呼ばれていた" + }, + "非型テンプレートパラメータ": { + "yomi": "ひかたてんぷれーとぱらめーた", + "redirect": "定数テンプレートパラメータ" } } diff --git a/GLOBAL_QUALIFY_LIST.txt b/GLOBAL_QUALIFY_LIST.txt index 0a2934b4c5..a849dd802e 100644 --- a/GLOBAL_QUALIFY_LIST.txt +++ b/GLOBAL_QUALIFY_LIST.txt @@ -232,6 +232,8 @@ * std::unique_ptr[link /reference/memory/unique_ptr.md] * addressof[link /reference/memory/addressof.md] * [link /reference/memory_resource.md] +* [link /reference/meta.md] + * std::meta::info[link /reference/meta/info.md] * [link /reference/mutex.md] * std::lock_guard[link /reference/mutex/lock_guard.md] * std::mutex[link /reference/mutex/mutex.md] @@ -302,6 +304,7 @@ * std::set[link /reference/set/set.md] * [link /reference/shared_mutex.md] * [link /reference/source_location.md] + * std::source_location[link /reference/source_location/source_location.md] * [link /reference/span.md] * std::dynamic_extent[link /reference/span/dynamic_extent.md] * std::span[link /reference/span/span.md] diff --git a/implementation-status.md b/implementation-status.md index 1deac837ff..8fea9650a8 100644 --- a/implementation-status.md +++ b/implementation-status.md @@ -326,7 +326,7 @@ | P2841R7: [コンセプトと変数テンプレートをテンプレート引数として渡せるようにする](/lang/cpp26/concept_and_variable-template_template-parameters.md) | テンプレートテンプレートパラメータとして、クラステンプレートやエイリアステンプレートに加え、コンセプトと変数テンプレートも渡せるようにする | | | | | | P1967R14: [ファイルを読み込む`#embed`命令を追加](/lang/cpp26/embed.md) | バイナリファイルをインクルードするメカニズム。`#include`とちがって読み出しサイズなどの柔軟な指定ができる | 15 | | | | | P3618R0: [`main`関数をグローバルモジュールに含められるようにする](/lang/cpp26/allow_attaching_main_to_the_global_module.md) | `main`関数に`extern "C++"`を指定できるようにすることで名前付きモジュールに含められるようにする | 16 | 21 | | | | -| P2996R13: [静的リフレクション](/lang/cpp26/reflection.md.nolink) | リフレクション演算子`^^`と`std::meta::info`型によりコンパイル時にさまざまな情報を取得できる | | | | | +| P2996R13: [静的リフレクション](/lang/cpp26/reflection.md) | リフレクション演算子`^^`と`std::meta::info`型によりコンパイル時にさまざまな情報を取得できる | | | | | | P1306R5: [コンパイル時のタプルやリストを展開処理する`template for`文](/lang/cpp26/expansion_statements.md) | タプル・構造体・Range・パラメータパックなどの各要素に対してコンパイル時に文を展開する`template for`文を追加 | 16 | | | | | P3533R2: [`constexpr`仮想継承を許可](/lang/cpp26/constexpr_virtual_inheritance.md) | 定数式の文脈での仮想継承を許可 | 16 | | | | | P2843R3: [プリプロセッサ仕様での「未定義動作」を不適格 (診断不要) に変更](/lang/cpp26/preprocessing_is_never_undefined.md) | プリプロセッサとレキサーの文脈での「未定義動作」用語を不適格 (診断不要) に変更 | 16 | | | | diff --git a/lang/cpp11/attributes.md b/lang/cpp11/attributes.md index 84d3ad7b09..7ba8a09a10 100644 --- a/lang/cpp11/attributes.md +++ b/lang/cpp11/attributes.md @@ -180,6 +180,8 @@ C++11で採用されたもの以外で検討された以下の機能は、属性 - [C++23 コード内容の仮定をコンパイラに伝える`assume`属性](/lang/cpp23/portable_assumptions.md) - [C++26 構造化束縛への属性を許可](/lang/cpp26/attributes_for_structured_bindings.md) - [C++26 未初期化変数の読み取りをエラー性動作とする (`[[indeterminate]]`属性)](/lang/cpp26/erroneous_behavior_for_uninitialized_reads.md) +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) + - 属性と同じ`[[`...`]]`構文を用いたアノテーション機能`[[=expr]]`が導入される。属性はコンパイラへのヒントだが、アノテーションはリフレクションで取得可能なユーザー定義のメタデータである ## 参照 diff --git a/lang/cpp20/immediate_functions.md b/lang/cpp20/immediate_functions.md index e629bcb059..163617895c 100644 --- a/lang/cpp20/immediate_functions.md +++ b/lang/cpp20/immediate_functions.md @@ -111,6 +111,8 @@ C++11で導入された`constexpr`指定子によって、関数を定数式評 * [C++20 コンパイル時初期化を強制する`constinit`キーワードを追加](constinit.md) * [C++23 `if consteval`](/lang/cpp23/if_consteval.md) * [C++23 `constexpr`関数内で`consteval`関数を呼び出せない問題を軽減](/lang/cpp23/consteval_needs_to_propagate_up.md) +* [C++26 静的リフレクション](/lang/cpp26/reflection.md) + * `consteval { ... }`ブロック構文が導入され、コンパイル時に副作用のあるコードを実行できるようになる ## 参照 diff --git a/lang/cpp26.md b/lang/cpp26.md index ff65d196e9..1435dda9e7 100644 --- a/lang/cpp26.md +++ b/lang/cpp26.md @@ -74,7 +74,7 @@ C++26とは、2026年中に改訂される予定の、C++バージョンの通 | 言語機能 | 説明 | |----------|------| -| [静的リフレクション](/lang/cpp26/reflection.md.nolink) | リフレクション演算子`^^`と`std::meta::info`型によりコンパイル時にさまざまな情報を取得できる | +| [静的リフレクション](/lang/cpp26/reflection.md) | リフレクション演算子`^^`と`std::meta::info`型によりコンパイル時にさまざまな情報を取得できる | | [コンパイル時のタプルやリストを展開処理する`template for`文](/lang/cpp26/expansion_statements.md) | タプル・構造体・Range・パラメータパックなどの各要素に対してコンパイル時に文を展開する`template for`文を追加 | | [定数式での`void*`からポインタ型へのキャストを許可](/lang/cpp26/constexpr_cast_from_voidptr.md) | 型消去のために`void*`からポインタ型へのキャストを許可する | | [`static_assert`の診断メッセージにユーザーが生成した文字列の指定を許可](/lang/cpp26/user-generated_static_assert_messages.md) | `constexpr`な`S.size()`と`S.data()`メンバ関数をもつオブジェクトをコンパイル時文字列として指定できるようにする | diff --git a/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md b/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md index d57fc92d18..eae2b2b382 100644 --- a/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md +++ b/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md @@ -56,6 +56,8 @@ const auto d = hello("Adolph Blaine Charles David Earl Frederick Gerald Hubert I - [`std::bad_typeid`](/reference/typeinfo/bad_typeid.md) - [``](/reference/stdexcept.md) - [`std::bad_expected_access`](/reference/expected/bad_expected_access.md) +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) + - リフレクションのメタ関数が不正な入力を受けた際のエラー報告として、コンパイル時の例外送出が使われる ## 参照 diff --git a/lang/cpp26/expansion_statements.md b/lang/cpp26/expansion_statements.md index c6fc6a598a..937aa412d4 100644 --- a/lang/cpp26/expansion_statements.md +++ b/lang/cpp26/expansion_statements.md @@ -192,7 +192,7 @@ C++23以前では、[`std::tuple`](/reference/tuple/tuple.md)のような異種 - [C++17 畳み込み式](/lang/cpp17/folding_expressions.md) - [C++17 構造化束縛](/lang/cpp17/structured_bindings.md) - [C++26 構造化束縛でパックを導入できるようにする](/lang/cpp26/structured_bindings_can_introduce_a_pack.md) -- [C++26 静的リフレクション](/lang/cpp26/reflection.md.nolink) +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) - [`std::tuple`](/reference/tuple/tuple.md) - [`std::apply()`](/reference/tuple/apply.md) diff --git a/lang/cpp26/feature_test_macros.md b/lang/cpp26/feature_test_macros.md index 3a7be0cd08..2527660021 100755 --- a/lang/cpp26/feature_test_macros.md +++ b/lang/cpp26/feature_test_macros.md @@ -21,7 +21,7 @@ |`__cpp_contracts`|`202502L`|[契約プログラミングをサポートする](/lang/cpp26/contracts.md)| |`__cpp_deleted_function`|`202403L`|[関数宣言を削除する理由を指定できるようにする](/lang/cpp26/delete_reason.md)| |`__cpp_expansion_statements`|`202506L`|[コンパイル時のタプルやリストを展開処理する`template for`文](/lang/cpp26/expansion_statements.md)| -|`__cpp_impl_reflection`|`202506L`|静的リフレクション| +|`__cpp_impl_reflection`|`202506L`|[静的リフレクション](/lang/cpp26/reflection.md)| |`__cpp_pack_indexing`|`202311L`|[パラメータパックへのインデックスアクセスを許可](/lang/cpp26/pack_indexing.md)| |`__cpp_placeholder_variables`|`202306L`|[宣言のみで使用しない変数の名前として`_`をサポート](/lang/cpp26/nice_placeholder_with_no_name.md)| |`__cpp_pp_embed`|`202502L`|[ファイルを読み込む`#embed`命令を追加](/lang/cpp26/embed.md)| @@ -75,7 +75,7 @@ |`__cpp_lib_copyable_function`|`202306L`|[``](/reference/functional.md)に[`std::copyable_function`](/reference/functional/copyable_function.md)を追加|[``](/reference/functional.md)| |`__cpp_lib_counting_scope`|`202506L`|[``](/reference/execution.md)に[`std::execution::spawn`](/reference/execution/execution/spawn.md)、[`std::execution::scope_token`](/reference/execution/execution/scope_token.md)などを追加|[``](/reference/execution.md)| |`__cpp_lib_debugging`|`202403L`|デバッグサポートのライブラリとして[``](/reference/debugging.md)を追加|[``](/reference/debugging.md)| -|`__cpp_lib_define_static`|`202506L`||[``](/reference/meta.md.nolink)| +|`__cpp_lib_define_static`|`202506L`||[``](/reference/meta.md)| |`__cpp_lib_exception_ptr_cast`|`202506L`|[`std::exception_ptr`](/reference/exception/exception_ptr.md)を指定した例外型にキャストする[`std::exception_ptr_cast()`](/reference/exception/exception_ptr_cast.md)関数を追加|[``](/reference/exception.md)| |`__cpp_lib_format`|`202311L`||[``](/reference/format.md)| |`__cpp_lib_format_path`|`202506L`|[`std::filesystem::path`](/reference/filesystem/path.md)クラスに、文字列フォーマットのサポートを追加
[`std::filesystem::path`](/reference/filesystem/path.md)クラスに、出力用の文字列を取得するためのメンバ関数を追加|[``](/reference/filesystem.md)| @@ -138,7 +138,7 @@ |`__cpp_lib_raw_memory_algorithms`|`202411L`|[`std::uninitialized_default_construct()`](/reference/memory/uninitialized_default_construct.md)などの未初期化領域に対する操作を`constexpr`対応|[``](/reference/memory.md)| |`__cpp_lib_rcu`|`202306L`|RCU (Read Copy Update) のライブラリとして[``](/reference/rcu.md)を追加|[``](/reference/rcu.md)| |`__cpp_lib_reference_wrapper`|`202403L`|[`std::reference_wrapper`](/reference/functional/reference_wrapper.md)に、比較演算子[`==`](/reference/functional/reference_wrapper/op_equal.md)と[`<=>`](/reference/functional/reference_wrapper/op_compare_3way.md)を追加|[``](/reference/functional.md)| -|`__cpp_lib_reflection`|`202506L`||[``](/reference/meta.md.nolink)| +|`__cpp_lib_reflection`|`202506L`|[静的リフレクション](/lang/cpp26/reflection.md)のライブラリ機能|[``](/reference/meta.md)| |`__cpp_lib_saturation_arithmetic`|`202311L`|[``](/reference/numeric.md)に飽和演算 (Saturation Arithmetic) として[`std::add_sat()`](/reference/numeric/add_sat.md)などの関数を追加|[``](/reference/numeric.md)| |`__cpp_lib_senders`|`202506L`||[``](/reference/execution.md)| |`__cpp_lib_simd`|`202506L`|データ並列ライブラリとして、[``](/reference/simd.md.nolink)を追加|[``](/reference/simd.md.nolink)| diff --git a/lang/cpp26/reflection.md b/lang/cpp26/reflection.md new file mode 100644 index 0000000000..6fd48a3648 --- /dev/null +++ b/lang/cpp26/reflection.md @@ -0,0 +1,402 @@ +# 静的リフレクション [P2996R13] +* cpp26[meta cpp] + + + +このページはC++26に採用される見込みの言語機能の変更を解説しています。 + +のちのC++規格でさらに変更される場合があるため[関連項目](#relative-page)を参照してください。 + + + +## 概要 +C++26では、コンパイル時にプログラムの構造を検査・操作できる「静的リフレクション (static reflection)」機能を導入する。 + +この機能は以下の要素で構成される: + +- **リフレクション演算子`^^`** : 型、名前空間、変数、関数、メンバなどのプログラム要素から、その情報を表すコンパイル時の値(リフレクション)を生成する +- **スプライス演算子`[: :]`** : リフレクションをプログラム要素(型、式、テンプレート引数など)に変換して挿入する +- **`std::meta::info`型** : リフレクションを表すスカラ型。構造的型 (structural type) であり、定数テンプレートパラメータとして使用できる +- **``ヘッダ** : リフレクションを操作するためのメタ関数群を提供する新しいヘッダ +- **`consteval`ブロック** : `consteval { ... }`によるコンパイル時副作用の実行 +- **アノテーション** : 宣言にコンパイル時定数を付加し、リフレクションで取得できる機構 +- **関数パラメータのリフレクション** : 関数の仮引数の型、名前、デフォルト引数の有無などをリフレクションで取得できる + +```cpp +#include +#include + +enum class Color { red, green, blue }; + +// 列挙値を文字列に変換する汎用関数 +template + requires std::is_enum_v +constexpr std::string_view to_string(E value) { + template for (constexpr auto e : std::meta::enumerators_of(^^E)) { // 型から列挙子のリストを取得 + if (value == [:e:]) { + return std::meta::identifier_of(e); // 列挙子の名前を文字列として取得 + } + } + return ""; +} + +int main() { + std::println("{}", to_string(Color::red)); // "red" + std::println("{}", to_string(Color::green)); // "green" + std::println("{}", to_string(Color::blue)); // "blue" +} +``` +* std::is_enum_v[link /reference/type_traits/is_enum.md] +* std::meta::enumerators_of[link /reference/meta/enumerators_of.md] +* std::meta::identifier_of[link /reference/meta/identifier_of.md] + + +## リフレクション演算子`^^` +`^^`は前置の単項演算子であり、プログラム要素から[`std::meta::info`](/reference/meta/info.md)型の値を生成する。 + +```cpp +constexpr auto r1 = ^^int; // 型のリフレクション +constexpr auto r2 = ^^std; // 名前空間のリフレクション +constexpr auto r3 = ^^::; // グローバル名前空間のリフレクション +constexpr auto r4 = ^^std::vector; // テンプレートのリフレクション +``` + +リフレクションできる対象と、取得できる主な情報: + +| 対象 | 構文例 | 取得できる情報 | +|------|--------|----------------| +| 型 | `^^int`, `^^std::string` | 名前、サイズ、アライメント、型特性、メンバ一覧、基底クラス一覧 | +| 名前空間 | `^^std`, `^^::` | 名前、メンバ一覧 | +| 変数 | `^^x` | 名前、型、記憶域期間、リンケージ | +| 関数 | `^^f` | 名前、戻り値型、パラメータ一覧、`noexcept`の有無 | +| 非静的データメンバ | `^^S::m` | 名前、型、オフセット、アクセス指定子、ビットフィールドの有無 | +| 列挙子 | `^^Color::red` | 名前、値、所属する列挙型 | +| テンプレート | `^^std::vector` | 名前、テンプレート引数の置換 | +| 基底クラス関係 | [`bases_of()`](/reference/meta/bases_of.md)経由 | 基底クラスの型、アクセス指定子、`virtual`の有無 | +| 関数パラメータ | [`parameters_of()`](/reference/meta/parameters_of.md)経由 | 名前、型、デフォルト引数の有無、明示的オブジェクトパラメータか | + +### オーバーロードされた関数のリフレクション +`^^f`で関数`f`をリフレクションする場合、`f`がオーバーロードされていると不適格となる。`^^`はオーバーロード集合ではなく単一の関数を対象とする。 + +```cpp +void f(int); +void f(double); + +// constexpr auto r = ^^f; // エラー: fはオーバーロードされている +``` + +オーバーロードされた関数の個々のオーバーロードを取得するには、[`members_of()`](/reference/meta/members_of.md)を使用する。`members_of()`は各オーバーロードを個別のリフレクションとして返す。 + +```cpp +struct S { + void f(int); + void f(double); +}; + +// members_of()で個々のオーバーロードを取得 +constexpr auto members = std::meta::members_of( + ^^S, std::meta::access_context::unchecked()); +// フィルタリングで特定のオーバーロードを選択できる +``` +* std::meta::members_of[link /reference/meta/members_of.md] +* std::meta::access_context[link /reference/meta/access_context.md] +* unchecked[link /reference/meta/access_context/unchecked.md] + +また、スプライスで関数のリフレクションを式に変換する場合、オーバーロード解決は行われず、そのリフレクションが表す特定の関数が直接使用される。 + + +## スプライス演算子`[: :]` +スプライス演算子は、[`std::meta::info`](/reference/meta/info.md)型の値(リフレクション)を受け取り、それが表すプログラム要素(型、式、テンプレート、名前空間)に変換して挿入する。`[:`と`:]`の間には`std::meta::info`型に評価される式を記述する。 + +```cpp +// 型スプライス:リフレクションが表す型を挿入する +constexpr std::meta::info r = ^^int; +typename[:r:] x = 42; // int x = 42; と等価 + +// 式スプライス:リフレクションが表す変数や関数を式として挿入する +int value = 10; +constexpr std::meta::info rv = ^^value; +[:rv:] = 20; // value = 20; と等価 +``` + +リフレクションが表す要素の種類に応じて、スプライスの構文が異なる: + +| 種類 | 構文 | 用途 | +|------|------|------| +| 型スプライス | `typename[:r:]` | リフレクション`r`が表す型を挿入。型のみの文脈では`typename`を省略可能 | +| 式スプライス | `[:r:]` | リフレクション`r`が表す変数・関数・列挙子などを式として挿入 | +| テンプレートスプライス | `template[:r:]` | リフレクション`r`が表すテンプレートを挿入 | +| 名前空間スプライス | `namespace[:r:]` | リフレクション`r`が表す名前空間を挿入 | + +メンバアクセスにもスプライスを使用できる。`obj.[:r:]`の形式で、リフレクション`r`が表す非静的データメンバや基底クラスにアクセスする: + +```cpp +struct S { int x; int y; }; +S s{1, 2}; + +constexpr auto members = std::meta::nonstatic_data_members_of( + ^^S, std::meta::access_context::unchecked()); + +int a = s.[:members[0]:]; // s.x と等価。a == 1 +int b = s.[:members[1]:]; // s.y と等価。b == 2 +``` +* std::meta::nonstatic_data_members_of[link /reference/meta/nonstatic_data_members_of.md] +* std::meta::access_context[link /reference/meta/access_context.md] +* unchecked[link /reference/meta/access_context/unchecked.md] + +### 基底クラスのサブオブジェクトへのスプライス +基底クラスのリフレクションに対してもメンバアクセスのスプライスを使用できる。これにより、非静的データメンバと基底クラスを統一的に扱うことができる。 + +```cpp +struct Base { int b; }; +struct Derived : Base { int d; }; + +Derived obj{{42}, 100}; +constexpr auto bases = std::meta::bases_of( + ^^Derived, std::meta::access_context::unchecked()); +Base& base_ref = obj.[:bases[0]:]; // 基底クラスのサブオブジェクトへの参照 +``` +* std::meta::bases_of[link /reference/meta/bases_of.md] +* std::meta::access_context[link /reference/meta/access_context.md] +* unchecked[link /reference/meta/access_context/unchecked.md] + +## `std::meta::info`型 +[`std::meta::info`](/reference/meta/info.md)型は、リフレクションを表す基本的な型である。 + +- [``](/reference/meta.md)ヘッダで`using info = decltype(^^::);`として定義される。`^^::`はグローバル名前空間のリフレクションを生成する式であり、`decltype`でその型を取得している +- スカラ型であり、クラス型ではない +- `==`と`!=`をサポートするが、順序比較(`<`, `>`, `<=>`)はサポートしない +- 構造的型 (structural type) であり、定数テンプレートパラメータとして使用できる +- consteval-only型であり、実行時には存在できない + +```cpp +// 定数テンプレートパラメータとして使用する例 +template +using type_of_reflection = typename[:R:]; + +type_of_reflection<^^int> x = 42; // int x = 42; +``` + +2つのリフレクションは、同じエンティティを反映している場合に等値となる。型の別名は、元の型とは区別される: + +```cpp +using MyInt = int; +static_assert(^^int != ^^MyInt); // 型の別名は区別される +static_assert(^^int == std::meta::dealias(^^MyInt)); // dealias()で元の型を取得 +``` +* std::meta::dealias[link /reference/meta/dealias.md] + + +## ``ヘッダのメタ関数 +[``](/reference/meta.md)ヘッダは、リフレクションを操作するための多数の`consteval`メタ関数を提供する。名前の取得、エンティティの分類・検査、メンバや基底クラスの列挙、型特性の判定と型変換、テンプレート操作、レイアウト情報の取得、集成体型の動的定義など、広範な機能を備える。 + +詳細は[``ヘッダのリファレンス](/reference/meta.md)を参照。 + + +## `consteval`ブロック +`consteval { ... }`構文により、コンパイル時に副作用のあるコードを実行できる。[`std::meta::define_aggregate()`](/reference/meta/define_aggregate.md)と組み合わせて型を動的に生成する際に使用する。 + +```cpp +struct S; + +consteval { + // Sを2つのintメンバを持つ集成体として定義 + std::meta::define_aggregate(^^S, { + std::meta::data_member_spec(^^int, {.name = "x"}), + std::meta::data_member_spec(^^int, {.name = "y"}) + }); +} + +S s{1, 2}; // s.x == 1, s.y == 2 +``` +* std::meta::define_aggregate[link /reference/meta/define_aggregate.md] +* std::meta::data_member_spec[link /reference/meta/data_member_spec.md] + + +## アノテーション +宣言にコンパイル時定数値を付加し、リフレクションで取得できる機構である。属性とは異なり、ユーザー定義の意味的データを運ぶ。 + +### 構文 +`[[=定数式]]`の構文でアノテーションを付加する。`=`接頭辞により通常の属性と区別される。 + +```cpp +struct [[=1]] Annotated { + [[=42, =24]] int value; +}; +``` + +アノテーションの式は構造的型でなければならない。アノテーションの取得には[`annotations_of()`](/reference/meta/annotations_of.md)や[`annotations_of_with_type()`](/reference/meta/annotations_of_with_type.md)メタ関数を使用する。 + +```cpp +struct Name { const char* value; }; + +struct [[=Name{std::define_static_string("点")}]] Point { + [[=Name{std::define_static_string("x座標")}]] int x; + [[=Name{std::define_static_string("y座標")}]] int y; +}; + +// メンバのアノテーションを取得 +template for (constexpr auto m : + std::meta::nonstatic_data_members_of(^^Point, + std::meta::access_context::unchecked())) { + constexpr auto annots = std::meta::annotations_of_with_type(m, ^^Name); + if constexpr (annots.size() > 0) { + std::println("{}: {}", [:annots[0]:].value, + std::meta::identifier_of(m)); + } +} +// 出力: +// x座標: x +// y座標: y +``` +* std::meta::nonstatic_data_members_of[link /reference/meta/nonstatic_data_members_of.md] +* std::meta::access_context[link /reference/meta/access_context.md] +* unchecked[link /reference/meta/access_context/unchecked.md] +* std::meta::annotations_of_with_type[link /reference/meta/annotations_of_with_type.md] + + +## `define_static_string` / `define_static_array` / `define_static_object` +これらは、コンパイル時に計算した値を静的ストレージに配置し、実行時に使用可能にするための関数群である。[`std::define_static_string()`](/reference/meta/define_static_string.md)は文字列を、[`std::define_static_array()`](/reference/meta/define_static_array.md)は配列を、[`std::define_static_object()`](/reference/meta/define_static_object.md)はオブジェクトをそれぞれ静的ストレージに配置する。これらは``ヘッダで提供されるが、`std`名前空間に定義される(`std::meta`名前空間ではない)。 + +```cpp +// コンパイル時に計算した文字列を実行時に使用する +template + requires std::is_enum_v +constexpr std::string_view enum_to_string(E value) { + template for (constexpr auto e : std::meta::enumerators_of(^^E)) { + if (value == [:e:]) { + return std::define_static_string(std::meta::identifier_of(e)); + } + } + return ""; +} +``` +* std::meta::enumerators_of[link /reference/meta/enumerators_of.md] +* std::meta::identifier_of[link /reference/meta/identifier_of.md] +* std::define_static_string[link /reference/meta/define_static_string.md] + + +## リフレクションのエラー処理 +リフレクションのメタ関数は、不正な入力に対して[`std::meta::exception`](/reference/meta/exception.md)を送出する。定数評価中の例外処理として動作するため、実行時のオーバーヘッドはない。 + + +## 例 +### 構造体のメンバを列挙する +```cpp example +#include +#include +#include + +struct Point { + int x; + int y; + std::string name; +}; + +int main() { + Point p{10, 20, "origin"}; + + template for (constexpr auto m : + std::meta::nonstatic_data_members_of(^^Point, + std::meta::access_context::unchecked())) { + std::println("{}: {}", std::meta::identifier_of(m), p.[:m:]); + } +} +``` +* std::meta::nonstatic_data_members_of[link /reference/meta/nonstatic_data_members_of.md] +* std::meta::access_context[link /reference/meta/access_context.md] +* unchecked[link /reference/meta/access_context/unchecked.md] +* std::meta::identifier_of[link /reference/meta/identifier_of.md] + +#### 出力 +``` +x: 10 +y: 20 +name: origin +``` + + +### 列挙値を文字列に変換する +```cpp example +#include +#include +#include + +enum class Color { red, green, blue }; + +template + requires std::is_enum_v +constexpr std::string_view to_string(E value) { + template for (constexpr auto e : std::meta::enumerators_of(^^E)) { + if (value == [:e:]) { + return std::meta::identifier_of(e); + } + } + return ""; +} + +int main() { + std::println("{}", to_string(Color::red)); + std::println("{}", to_string(Color::green)); + std::println("{}", to_string(Color::blue)); +} +``` +* std::is_enum_v[link /reference/type_traits/is_enum.md] +* std::meta::enumerators_of[link /reference/meta/enumerators_of.md] +* std::meta::identifier_of[link /reference/meta/identifier_of.md] + +#### 出力 +``` +red +green +blue +``` + + +### 関数パラメータの名前と型を列挙する +```cpp example +#include +#include + +void process(int id, double value, const char* name) {} + +int main() { + template for (constexpr auto p : std::meta::parameters_of(^^process)) { + std::println("パラメータ: {} (型: {})", + std::meta::identifier_of(p), + std::meta::display_string_of(std::meta::type_of(p))); + } +} +``` +* std::meta::parameters_of[link /reference/meta/parameters_of.md] +* std::meta::identifier_of[link /reference/meta/identifier_of.md] +* std::meta::display_string_of[link /reference/meta/display_string_of.md] +* std::meta::type_of[link /reference/meta/type_of.md] + +#### 出力 +``` +パラメータ: id (型: int) +パラメータ: value (型: double) +パラメータ: name (型: const char*) +``` + + +## 関連項目 +- [``ヘッダ](/reference/meta.md) +- [C++26 コンパイル時のタプルやリストを展開処理する`template for`文](/lang/cpp26/expansion_statements.md) +- [C++26 定数評価での例外送出を許可](/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) + - C++26での静的リフレクションの基本機能。リフレクション演算子`^^`、スプライス演算子`[: :]`、`std::meta::info`型、``ヘッダのメタ関数群を導入する。 +- [P3394R4 Annotations for Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3394r4.html) + - 宣言にコンパイル時定数を付加するアノテーション機能`[[=expr]]`と、それを取得するための`annotations_of()`メタ関数を追加する。 +- [P3293R3 Splicing a base class subobject](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html) + - 基底クラスのリフレクションに対するメンバアクセスのスプライス`obj.[:base:]`と、基底クラスと非静的データメンバを統合取得する`subobjects_of()`を追加する。 +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) + - 関数パラメータのリフレクションを追加する。`parameters_of()`、`return_type_of()`、`has_default_argument()`などのメタ関数を導入する。 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) + - コンパイル時に計算した値を静的ストレージに配置するための`define_static_string()`、`define_static_array()`、`define_static_object()`を追加する。 +- [P3560R2 Error Handling in Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3560r2.html) + - リフレクションのメタ関数のエラー処理として`std::meta::exception`例外クラスを導入する。コンパイル時例外として動作する。 diff --git a/reference.md b/reference.md index 0263706afc..61d8bfc5c8 100644 --- a/reference.md +++ b/reference.md @@ -77,6 +77,7 @@ | [``](/reference/charconv.md) | 高速な文字列 ⇔ 数値変換 | C++17 | | [``](/reference/format.md) | 文字列フォーマット | C++20 | | [``](/reference/stacktrace.md) | スタックトレース | C++23 | +| [``](/reference/meta.md) | 静的リフレクション | C++26 | ## 文字列ライブラリ diff --git a/reference/meta.md b/reference/meta.md new file mode 100644 index 0000000000..fe0fd6609f --- /dev/null +++ b/reference/meta.md @@ -0,0 +1,432 @@ +# meta +* meta[meta header] +* cpp26[meta cpp] + +``ヘッダでは、[静的リフレクション](/lang/cpp26/reflection.md)のためのメタ関数群を定義する。リフレクション演算子`^^`で取得した[`std::meta::info`](meta/info.md)型の値を操作・検査するための機能を提供する。 + +このヘッダのすべての関数は`consteval`であり、コンパイル時にのみ使用できる。 + + +## リフレクション型 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`info`](meta/info.md) | リフレクションを表す型 (`using info = decltype(^^::);`) | C++26 | + + +## コンセプト + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`reflection_range`](meta/reflection_range.md) | 要素型が`info`であるRange (concept) | C++26 | + + +## アクセス制御 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`access_context`](meta/access_context.md) | メンバ取得時のアクセス制御コンテキスト (class) | C++26 | + + +## 演算子 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`operators`](meta/operators.md) | 演算子の種類を表す列挙型 (enum class) | C++26 | +| [`operator_of`](meta/operator_of.md) | 演算子のリフレクションから演算子の種類を取得 | C++26 | +| [`symbol_of`](meta/symbol_of.md) | 演算子の種類から記号文字列を取得 | C++26 | +| [`u8symbol_of`](meta/symbol_of.md) | 演算子の種類から記号文字列を`u8string_view`で取得 | C++26 | + + +## 名前とソース位置 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`has_identifier`](meta/has_identifier.md) | 識別子を持つかどうかを判定 | C++26 | +| [`identifier_of`](meta/identifier_of.md) | 識別子を`string_view`で取得 | C++26 | +| [`u8identifier_of`](meta/identifier_of.md) | 識別子を`u8string_view`で取得 | C++26 | +| [`display_string_of`](meta/display_string_of.md) | 表示用の文字列を`string_view`で取得 | C++26 | +| [`u8display_string_of`](meta/display_string_of.md) | 表示用の文字列を`u8string_view`で取得 | C++26 | +| [`source_location_of`](meta/source_location_of.md) | ソース位置を取得 | C++26 | + + +## エンティティの性質 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`type_of`](meta/type_of.md) | 型のリフレクションを取得 | C++26 | +| [`object_of`](meta/object_of.md) | オブジェクトのリフレクションを取得 | C++26 | +| [`constant_of`](meta/constant_of.md) | 定数のリフレクションを取得 | C++26 | +| [`dealias`](meta/dealias.md) | エイリアスを解決する | C++26 | +| [`has_parent`](meta/has_parent.md) | 親スコープがあるかどうかを判定 | C++26 | +| [`parent_of`](meta/parent_of.md) | 親スコープのリフレクションを取得 | C++26 | + + +## アクセス指定子 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_public`](meta/is_public.md) | `public`であるか | C++26 | +| [`is_protected`](meta/is_protected.md) | `protected`であるか | C++26 | +| [`is_private`](meta/is_private.md) | `private`であるか | C++26 | +| [`is_accessible`](meta/is_accessible.md) | 指定したアクセスコンテキストでアクセス可能か | C++26 | +| [`has_inaccessible_nonstatic_data_members`](meta/has_inaccessible_nonstatic_data_members.md) | アクセス不可能な非静的データメンバがあるか | C++26 | +| [`has_inaccessible_bases`](meta/has_inaccessible_bases.md) | アクセス不可能な基底クラスがあるか | C++26 | + + +## エンティティの分類 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_variable`](meta/is_variable.md) | 変数であるか | C++26 | +| [`is_type`](meta/is_type.md) | 型であるか | C++26 | +| [`is_namespace`](meta/is_namespace.md) | 名前空間であるか | C++26 | +| [`is_type_alias`](meta/is_type_alias.md) | 型エイリアスであるか | C++26 | +| [`is_namespace_alias`](meta/is_namespace_alias.md) | 名前空間エイリアスであるか | C++26 | +| [`is_function`](meta/is_function.md) | 関数であるか | C++26 | +| [`is_enumerator`](meta/is_enumerator.md) | 列挙子であるか | C++26 | +| [`is_value`](meta/is_value.md) | 値であるか | C++26 | +| [`is_object`](meta/is_object.md) | オブジェクトであるか | C++26 | +| [`is_structured_binding`](meta/is_structured_binding.md) | 構造化束縛であるか | C++26 | +| [`is_class_member`](meta/is_class_member.md) | クラスメンバであるか | C++26 | +| [`is_namespace_member`](meta/is_namespace_member.md) | 名前空間メンバであるか | C++26 | +| [`is_nonstatic_data_member`](meta/is_nonstatic_data_member.md) | 非静的データメンバであるか | C++26 | +| [`is_static_member`](meta/is_static_member.md) | 静的メンバであるか | C++26 | +| [`is_base`](meta/is_base.md) | 基底クラス関係であるか | C++26 | +| [`is_function_parameter`](meta/is_function_parameter.md) | 関数パラメータであるか | C++26 | +| [`is_template`](meta/is_template.md) | テンプレートであるか | C++26 | +| [`is_function_template`](meta/is_function_template.md) | 関数テンプレートであるか | C++26 | +| [`is_variable_template`](meta/is_variable_template.md) | 変数テンプレートであるか | C++26 | +| [`is_class_template`](meta/is_class_template.md) | クラステンプレートであるか | C++26 | +| [`is_alias_template`](meta/is_alias_template.md) | エイリアステンプレートであるか | C++26 | +| [`is_conversion_function_template`](meta/is_conversion_function_template.md) | 変換関数テンプレートであるか | C++26 | +| [`is_operator_function_template`](meta/is_operator_function_template.md) | 演算子関数テンプレートであるか | C++26 | +| [`is_literal_operator_template`](meta/is_literal_operator_template.md) | リテラル演算子テンプレートであるか | C++26 | +| [`is_constructor_template`](meta/is_constructor_template.md) | コンストラクタテンプレートであるか | C++26 | +| [`is_concept`](meta/is_concept.md) | コンセプトであるか | C++26 | +| [`is_complete_type`](meta/is_complete_type.md) | 完全型であるか | C++26 | +| [`is_enumerable_type`](meta/is_enumerable_type.md) | 列挙可能型であるか | C++26 | + + +## 関数の分類 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_conversion_function`](meta/is_conversion_function.md) | 変換関数であるか | C++26 | +| [`is_operator_function`](meta/is_operator_function.md) | 演算子関数であるか | C++26 | +| [`is_literal_operator`](meta/is_literal_operator.md) | リテラル演算子であるか | C++26 | +| [`is_special_member_function`](meta/is_special_member_function.md) | 特殊メンバ関数であるか | C++26 | +| [`is_constructor`](meta/is_constructor.md) | コンストラクタであるか | C++26 | +| [`is_default_constructor`](meta/is_default_constructor.md) | デフォルトコンストラクタであるか | C++26 | +| [`is_copy_constructor`](meta/is_copy_constructor.md) | コピーコンストラクタであるか | C++26 | +| [`is_move_constructor`](meta/is_move_constructor.md) | ムーブコンストラクタであるか | C++26 | +| [`is_assignment`](meta/is_assignment.md) | 代入演算子であるか | C++26 | +| [`is_copy_assignment`](meta/is_copy_assignment.md) | コピー代入演算子であるか | C++26 | +| [`is_move_assignment`](meta/is_move_assignment.md) | ムーブ代入演算子であるか | C++26 | +| [`is_destructor`](meta/is_destructor.md) | デストラクタであるか | C++26 | +| [`is_deleted`](meta/is_deleted.md) | `= delete`されているか | C++26 | +| [`is_defaulted`](meta/is_defaulted.md) | `= default`されているか | C++26 | +| [`is_explicit`](meta/is_explicit.md) | `explicit`であるか | C++26 | +| [`is_noexcept`](meta/is_noexcept.md) | `noexcept`であるか | C++26 | +| [`is_user_provided`](meta/is_user_provided.md) | ユーザー提供であるか | C++26 | +| [`is_user_declared`](meta/is_user_declared.md) | ユーザー宣言であるか | C++26 | + + +## 関数パラメータの検査 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`parameters_of`](meta/parameters_of.md) | 関数パラメータのリフレクションを取得 | C++26 | +| [`return_type_of`](meta/return_type_of.md) | 関数の戻り値型のリフレクションを取得 | C++26 | +| [`variable_of`](meta/variable_of.md) | パラメータ変数のリフレクションを取得 | C++26 | +| [`has_default_argument`](meta/has_default_argument.md) | デフォルト引数を持つか | C++26 | +| [`has_ellipsis_parameter`](meta/has_ellipsis_parameter.md) | 可変長引数を持つか | C++26 | +| [`is_explicit_object_parameter`](meta/is_explicit_object_parameter.md) | 明示的オブジェクトパラメータであるか | C++26 | + + +## メンバの性質 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_virtual`](meta/is_virtual.md) | `virtual`であるか | C++26 | +| [`is_pure_virtual`](meta/is_pure_virtual.md) | 純粋仮想であるか | C++26 | +| [`is_override`](meta/is_override.md) | `override`であるか | C++26 | +| [`is_final`](meta/is_final.md) | `final`であるか | C++26 | +| [`is_const`](meta/is_const.md) | `const`修飾されているか | C++26 | +| [`is_volatile`](meta/is_volatile.md) | `volatile`修飾されているか | C++26 | +| [`is_mutable_member`](meta/is_mutable_member.md) | `mutable`メンバであるか | C++26 | +| [`is_lvalue_reference_qualified`](meta/is_lvalue_reference_qualified.md) | 左辺値参照修飾されているか | C++26 | +| [`is_rvalue_reference_qualified`](meta/is_rvalue_reference_qualified.md) | 右辺値参照修飾されているか | C++26 | +| [`is_bit_field`](meta/is_bit_field.md) | ビットフィールドであるか | C++26 | +| [`has_default_member_initializer`](meta/has_default_member_initializer.md) | デフォルトメンバ初期化子を持つか | C++26 | + + +## 記憶域とリンケージ + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`has_static_storage_duration`](meta/has_static_storage_duration.md) | 静的記憶域期間を持つか | C++26 | +| [`has_thread_storage_duration`](meta/has_thread_storage_duration.md) | スレッド記憶域期間を持つか | C++26 | +| [`has_automatic_storage_duration`](meta/has_automatic_storage_duration.md) | 自動記憶域期間を持つか | C++26 | +| [`has_internal_linkage`](meta/has_internal_linkage.md) | 内部リンケージを持つか | C++26 | +| [`has_module_linkage`](meta/has_module_linkage.md) | モジュールリンケージを持つか | C++26 | +| [`has_external_linkage`](meta/has_external_linkage.md) | 外部リンケージを持つか | C++26 | +| [`has_c_language_linkage`](meta/has_c_language_linkage.md) | C言語リンケージを持つか | C++26 | +| [`has_linkage`](meta/has_linkage.md) | リンケージを持つか | C++26 | + + +## メンバ・基底クラスの取得 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`members_of`](meta/members_of.md) | すべてのメンバを取得 | C++26 | +| [`bases_of`](meta/bases_of.md) | 基底クラスを取得 | C++26 | +| [`static_data_members_of`](meta/static_data_members_of.md) | 静的データメンバを取得 | C++26 | +| [`nonstatic_data_members_of`](meta/nonstatic_data_members_of.md) | 非静的データメンバを取得 | C++26 | +| [`enumerators_of`](meta/enumerators_of.md) | 列挙子を取得 | C++26 | +| [`subobjects_of`](meta/subobjects_of.md) | 基底クラスと非静的データメンバを統合して取得 | C++26 | + + +## テンプレート操作 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`has_template_arguments`](meta/has_template_arguments.md) | テンプレート引数を持つか | C++26 | +| [`template_of`](meta/template_of.md) | テンプレートのリフレクションを取得 | C++26 | +| [`template_arguments_of`](meta/template_arguments_of.md) | テンプレート引数のリフレクションを取得 | C++26 | +| [`can_substitute`](meta/can_substitute.md) | テンプレート引数が置換可能か判定 | C++26 | +| [`substitute`](meta/substitute.md) | テンプレートにテンプレート引数を適用 | C++26 | + + +## レイアウト情報 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`member_offset`](meta/member_offset.md) | メンバオフセットを表す型 (class) | C++26 | +| [`offset_of`](meta/offset_of.md) | メンバのオフセットを取得 | C++26 | +| [`size_of`](meta/size_of.md) | サイズを取得 | C++26 | +| [`alignment_of`](meta/alignment_of.md) | アライメントを取得 | C++26 | +| [`bit_size_of`](meta/bit_size_of.md) | ビットサイズを取得 | C++26 | + + +## 値の抽出と生成 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`extract`](meta/extract.md) | リフレクションから値を抽出 | C++26 | +| [`reflect_constant`](meta/reflect_constant.md) | 値からリフレクションを生成 | C++26 | +| [`reflect_object`](meta/reflect_object.md) | オブジェクトからリフレクションを生成 | C++26 | +| [`reflect_function`](meta/reflect_function.md) | 関数からリフレクションを生成 | C++26 | + + +## 集成体の定義 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`data_member_options`](meta/data_member_options.md) | データメンバの仕様を指定するオプション (class) | C++26 | +| [`data_member_spec`](meta/data_member_spec.md) | データメンバの仕様を作成 | C++26 | +| [`is_data_member_spec`](meta/is_data_member_spec.md) | データメンバの仕様であるか | C++26 | +| [`define_aggregate`](meta/define_aggregate.md) | 集成体型を定義 | C++26 | + + +## 静的ストレージへの配置 + +以下の`define_static_*`と`is_string_literal`は`std`名前空間に定義される(`std::meta`名前空間ではない)。`reflect_constant_*`は`std::meta`名前空間に定義される。 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`define_static_string`](meta/define_static_string.md) | コンパイル時文字列を静的ストレージに配置し`const CharT*`を返す | C++26 | +| [`define_static_array`](meta/define_static_array.md) | コンパイル時配列を静的ストレージに配置し`span`を返す | C++26 | +| [`define_static_object`](meta/define_static_object.md) | コンパイル時オブジェクトを静的ストレージに配置し`const T*`を返す | C++26 | +| [`reflect_constant_string`](meta/reflect_constant_string.md) | コンパイル時文字列のリフレクションを生成する | C++26 | +| [`reflect_constant_array`](meta/reflect_constant_array.md) | コンパイル時配列のリフレクションを生成する | C++26 | +| [`is_string_literal`](meta/is_string_literal.md) | ポインタが文字列リテラルを指しているかを判定する | C++26 | + + +## アノテーション + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_annotation`](meta/is_annotation.md) | アノテーションであるか | C++26 | +| [`annotations_of`](meta/annotations_of.md) | すべてのアノテーションを取得 | C++26 | +| [`annotations_of_with_type`](meta/annotations_of_with_type.md) | 指定した型のアノテーションのみ取得 | C++26 | + + +## 型特性(プライマリ型カテゴリ) + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_void_type`](meta/is_void_type.md) | `void`型か | C++26 | +| [`is_null_pointer_type`](meta/is_null_pointer_type.md) | `nullptr_t`型か | C++26 | +| [`is_integral_type`](meta/is_integral_type.md) | 整数型か | C++26 | +| [`is_floating_point_type`](meta/is_floating_point_type.md) | 浮動小数点数型か | C++26 | +| [`is_array_type`](meta/is_array_type.md) | 配列型か | C++26 | +| [`is_pointer_type`](meta/is_pointer_type.md) | ポインタ型か | C++26 | +| [`is_lvalue_reference_type`](meta/is_lvalue_reference_type.md) | 左辺値参照型か | C++26 | +| [`is_rvalue_reference_type`](meta/is_rvalue_reference_type.md) | 右辺値参照型か | C++26 | +| [`is_member_object_pointer_type`](meta/is_member_object_pointer_type.md) | メンバオブジェクトポインタ型か | C++26 | +| [`is_member_function_pointer_type`](meta/is_member_function_pointer_type.md) | メンバ関数ポインタ型か | C++26 | +| [`is_enum_type`](meta/is_enum_type.md) | 列挙型か | C++26 | +| [`is_union_type`](meta/is_union_type.md) | 共用体型か | C++26 | +| [`is_class_type`](meta/is_class_type.md) | クラス型か | C++26 | +| [`is_function_type`](meta/is_function_type.md) | 関数型か | C++26 | +| [`is_reflection_type`](meta/is_reflection_type.md) | リフレクション型か | C++26 | + + +## 型特性(複合型カテゴリ) + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_reference_type`](meta/is_reference_type.md) | 参照型か | C++26 | +| [`is_arithmetic_type`](meta/is_arithmetic_type.md) | 算術型か | C++26 | +| [`is_fundamental_type`](meta/is_fundamental_type.md) | 基本型か | C++26 | +| [`is_object_type`](meta/is_object_type.md) | オブジェクト型か | C++26 | +| [`is_scalar_type`](meta/is_scalar_type.md) | スカラ型か | C++26 | +| [`is_compound_type`](meta/is_compound_type.md) | 複合型か | C++26 | +| [`is_member_pointer_type`](meta/is_member_pointer_type.md) | メンバポインタ型か | C++26 | + + +## 型特性(型の性質) + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_const_type`](meta/is_const_type.md) | `const`型か | C++26 | +| [`is_volatile_type`](meta/is_volatile_type.md) | `volatile`型か | C++26 | +| [`is_trivially_copyable_type`](meta/is_trivially_copyable_type.md) | トリビアルコピー可能型か | C++26 | +| [`is_standard_layout_type`](meta/is_standard_layout_type.md) | スタンダードレイアウト型か | C++26 | +| [`is_empty_type`](meta/is_empty_type.md) | 空の型か | C++26 | +| [`is_polymorphic_type`](meta/is_polymorphic_type.md) | 多態的型か | C++26 | +| [`is_abstract_type`](meta/is_abstract_type.md) | 抽象型か | C++26 | +| [`is_final_type`](meta/is_final_type.md) | `final`型か | C++26 | +| [`is_aggregate_type`](meta/is_aggregate_type.md) | 集成体型か | C++26 | +| [`is_signed_type`](meta/is_signed_type.md) | 符号付き型か | C++26 | +| [`is_unsigned_type`](meta/is_unsigned_type.md) | 符号なし型か | C++26 | +| [`is_bounded_array_type`](meta/is_bounded_array_type.md) | 境界付き配列型か | C++26 | +| [`is_unbounded_array_type`](meta/is_unbounded_array_type.md) | 境界なし配列型か | C++26 | +| [`is_scoped_enum_type`](meta/is_scoped_enum_type.md) | スコープ付き列挙型か | C++26 | +| [`is_constructible_type`](meta/is_constructible_type.md) | 構築可能型か | C++26 | +| [`is_default_constructible_type`](meta/is_default_constructible_type.md) | デフォルト構築可能型か | C++26 | +| [`is_copy_constructible_type`](meta/is_copy_constructible_type.md) | コピー構築可能型か | C++26 | +| [`is_move_constructible_type`](meta/is_move_constructible_type.md) | ムーブ構築可能型か | C++26 | +| [`is_assignable_type`](meta/is_assignable_type.md) | 代入可能型か | C++26 | +| [`is_copy_assignable_type`](meta/is_copy_assignable_type.md) | コピー代入可能型か | C++26 | +| [`is_move_assignable_type`](meta/is_move_assignable_type.md) | ムーブ代入可能型か | C++26 | +| [`is_swappable_with_type`](meta/is_swappable_with_type.md) | 指定型とのswap可能型か | C++26 | +| [`is_swappable_type`](meta/is_swappable_type.md) | swap可能型か | C++26 | +| [`is_destructible_type`](meta/is_destructible_type.md) | 破棄可能型か | C++26 | +| [`is_trivially_constructible_type`](meta/is_trivially_constructible_type.md) | トリビアルに構築可能型か | C++26 | +| [`is_trivially_default_constructible_type`](meta/is_trivially_default_constructible_type.md) | トリビアルにデフォルト構築可能型か | C++26 | +| [`is_trivially_copy_constructible_type`](meta/is_trivially_copy_constructible_type.md) | トリビアルにコピー構築可能型か | C++26 | +| [`is_trivially_move_constructible_type`](meta/is_trivially_move_constructible_type.md) | トリビアルにムーブ構築可能型か | C++26 | +| [`is_trivially_assignable_type`](meta/is_trivially_assignable_type.md) | トリビアルに代入可能型か | C++26 | +| [`is_trivially_copy_assignable_type`](meta/is_trivially_copy_assignable_type.md) | トリビアルにコピー代入可能型か | C++26 | +| [`is_trivially_move_assignable_type`](meta/is_trivially_move_assignable_type.md) | トリビアルにムーブ代入可能型か | C++26 | +| [`is_trivially_destructible_type`](meta/is_trivially_destructible_type.md) | トリビアルに破棄可能型か | C++26 | +| [`is_nothrow_constructible_type`](meta/is_nothrow_constructible_type.md) | 例外を送出せずに構築可能型か | C++26 | +| [`is_nothrow_default_constructible_type`](meta/is_nothrow_default_constructible_type.md) | 例外を送出せずにデフォルト構築可能型か | C++26 | +| [`is_nothrow_copy_constructible_type`](meta/is_nothrow_copy_constructible_type.md) | 例外を送出せずにコピー構築可能型か | C++26 | +| [`is_nothrow_move_constructible_type`](meta/is_nothrow_move_constructible_type.md) | 例外を送出せずにムーブ構築可能型か | C++26 | +| [`is_nothrow_assignable_type`](meta/is_nothrow_assignable_type.md) | 例外を送出せずに代入可能型か | C++26 | +| [`is_nothrow_copy_assignable_type`](meta/is_nothrow_copy_assignable_type.md) | 例外を送出せずにコピー代入可能型か | C++26 | +| [`is_nothrow_move_assignable_type`](meta/is_nothrow_move_assignable_type.md) | 例外を送出せずにムーブ代入可能型か | C++26 | +| [`is_nothrow_swappable_with_type`](meta/is_nothrow_swappable_with_type.md) | 例外を送出せずに指定型とswap可能型か | C++26 | +| [`is_nothrow_swappable_type`](meta/is_nothrow_swappable_type.md) | 例外を送出せずにswap可能型か | C++26 | +| [`is_nothrow_destructible_type`](meta/is_nothrow_destructible_type.md) | 例外を送出せずに破棄可能型か | C++26 | +| [`is_consteval_only_type`](meta/is_consteval_only_type.md) | consteval-only型か | C++26 | +| [`is_implicit_lifetime_type`](meta/is_implicit_lifetime_type.md) | 暗黙の生存期間型か | C++26 | +| [`has_virtual_destructor`](meta/has_virtual_destructor.md) | 仮想デストラクタを持つか | C++26 | +| [`has_unique_object_representations`](meta/has_unique_object_representations.md) | 一意なオブジェクト表現を持つか | C++26 | +| [`reference_constructs_from_temporary`](meta/reference_constructs_from_temporary.md) | 参照が一時オブジェクトから構築されるか | C++26 | +| [`reference_converts_from_temporary`](meta/reference_converts_from_temporary.md) | 参照への変換が一時オブジェクトを経由するか | C++26 | + + + +## 型特性(型プロパティクエリ) + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`rank`](meta/rank.md) | 配列型の次元数を取得 | C++26 | +| [`extent`](meta/extent.md) | 配列型の指定次元の要素数を取得 | C++26 | + + +## 型特性(型の関係) + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`is_same_type`](meta/is_same_type.md) | 同じ型か | C++26 | +| [`is_base_of_type`](meta/is_base_of_type.md) | 基底クラスであるか | C++26 | +| [`is_virtual_base_of_type`](meta/is_virtual_base_of_type.md) | 仮想基底クラスであるか | C++26 | +| [`is_convertible_type`](meta/is_convertible_type.md) | 変換可能か | C++26 | +| [`is_nothrow_convertible_type`](meta/is_nothrow_convertible_type.md) | 例外を送出せずに変換可能か | C++26 | +| [`is_layout_compatible_type`](meta/is_layout_compatible_type.md) | レイアウト互換か | C++26 | +| [`is_pointer_interconvertible_base_of_type`](meta/is_pointer_interconvertible_base_of_type.md) | ポインタ相互変換可能な基底クラスか | C++26 | +| [`is_invocable_type`](meta/is_invocable_type.md) | 呼び出し可能か | C++26 | +| [`is_invocable_r_type`](meta/is_invocable_r_type.md) | 指定戻り値型で呼び出し可能か | C++26 | +| [`is_nothrow_invocable_type`](meta/is_nothrow_invocable_type.md) | 例外を送出せずに呼び出し可能か | C++26 | +| [`is_nothrow_invocable_r_type`](meta/is_nothrow_invocable_r_type.md) | 例外を送出せずに指定戻り値型で呼び出し可能か | C++26 | + +## 型変換 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`remove_const`](meta/remove_const.md) | `const`を除去 | C++26 | +| [`remove_volatile`](meta/remove_volatile.md) | `volatile`を除去 | C++26 | +| [`remove_cv`](meta/remove_cv.md) | CV修飾を除去 | C++26 | +| [`add_const`](meta/add_const.md) | `const`を付加 | C++26 | +| [`add_volatile`](meta/add_volatile.md) | `volatile`を付加 | C++26 | +| [`add_cv`](meta/add_cv.md) | CV修飾を付加 | C++26 | +| [`remove_reference`](meta/remove_reference.md) | 参照を除去 | C++26 | +| [`add_lvalue_reference`](meta/add_lvalue_reference.md) | 左辺値参照を付加 | C++26 | +| [`add_rvalue_reference`](meta/add_rvalue_reference.md) | 右辺値参照を付加 | C++26 | +| [`remove_cvref`](meta/remove_cvref.md) | CV修飾と参照を除去 | C++26 | +| [`remove_pointer`](meta/remove_pointer.md) | ポインタを除去 | C++26 | +| [`add_pointer`](meta/add_pointer.md) | ポインタを付加 | C++26 | +| [`decay`](meta/decay.md) | 配列・関数からポインタへの変換を適用 | C++26 | +| [`make_signed`](meta/make_signed.md) | 符号付き型に変換 | C++26 | +| [`make_unsigned`](meta/make_unsigned.md) | 符号なし型に変換 | C++26 | +| [`remove_extent`](meta/remove_extent.md) | 配列の次元を除去 | C++26 | +| [`remove_all_extents`](meta/remove_all_extents.md) | 配列のすべての次元を除去 | C++26 | +| [`common_type`](meta/common_type.md) | 共通型を取得 | C++26 | +| [`common_reference`](meta/common_reference.md) | 共通参照型を取得 | C++26 | +| [`type_underlying_type`](meta/type_underlying_type.md) | 基底型を取得 | C++26 | +| [`invoke_result`](meta/invoke_result.md) | 呼び出し結果型を取得 | C++26 | +| [`unwrap_reference`](meta/unwrap_reference.md) | `reference_wrapper`を展開 | C++26 | +| [`unwrap_ref_decay`](meta/unwrap_ref_decay.md) | `decay`後に`reference_wrapper`を展開 | C++26 | +| [`tuple_size`](meta/tuple_size.md) | tuple-like型の要素数を取得 | C++26 | +| [`tuple_element`](meta/tuple_element.md) | tuple-like型の要素型を取得 | C++26 | +| [`variant_size`](meta/variant_size.md) | variant型の候補型の数を取得 | C++26 | +| [`variant_alternative`](meta/variant_alternative.md) | variant型の候補型を取得 | C++26 | +| [`type_order`](meta/type_order.md) | 型の順序を取得 | C++26 | + + +## エラー処理 + +| 名前 | 説明 | 対応バージョン | +|------|------|-------| +| [`exception`](meta/exception.md) | リフレクションメタ関数のエラーを表す例外クラス (class) | C++26 | + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) +- [C++26 コンパイル時のタプルやリストを展開処理する`template for`文](/lang/cpp26/expansion_statements.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3394R4 Annotations for Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3394r4.html) +- [P3293R3 Splicing a base class subobject](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) +- [P3560R2 Error Handling in Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3560r2.html) +- [P3920R0 Wording for NB comment resolution on trivial relocation](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3920r0.html) + - C++26策定中に、trivially relocatable関係が一旦削除された diff --git a/reference/meta/access_context.md b/reference/meta/access_context.md new file mode 100644 index 0000000000..926d29ae9c --- /dev/null +++ b/reference/meta/access_context.md @@ -0,0 +1,86 @@ +# access_context +* meta[meta header] +* std::meta[meta namespace] +* class[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + struct access_context; +} +``` + +## 概要 +`access_context`は、[`members_of()`](members_of.md)や[`bases_of()`](bases_of.md)などのメンバ取得関数で、アクセス制御のコンテキストを指定するためのクラスである。 + +## 静的メンバ関数 + +| 名前 | 説明 | +|------|------| +| [`current`](access_context/current.md) | 呼び出し元のアクセス権に従うコンテキストを返す | +| [`unprivileged`](access_context/unprivileged.md) | `public`メンバのみにアクセス可能なコンテキストを返す | +| [`unchecked`](access_context/unchecked.md) | すべてのメンバにアクセス制限なしでアクセス可能なコンテキストを返す | + +## メンバ関数 + +| 名前 | 説明 | +|------|------| +| [`scope`](access_context/scope.md) | アクセスコンテキストのスコープのリフレクションを返す | +| [`designating_class`](access_context/designating_class.md) | 指定クラスのリフレクションを返す | +| [`via`](access_context/via.md) | 指定したクラスを経由したアクセスコンテキストを返す | + +## 例 +```cpp example +#include +#include + +class MyClass { + int secret = 42; +public: + int visible = 1; +}; + +int main() { + // unchecked: すべてのメンバにアクセス + std::println("unchecked:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^MyClass, std::meta::access_context::unchecked())) { + std::println(" {}", std::meta::identifier_of(m)); + } + + // unprivileged: publicのみ + std::println("unprivileged:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^MyClass, std::meta::access_context::unprivileged())) { + std::println(" {}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::identifier_of[link identifier_of.md] +* unchecked[link access_context/unchecked.md] +* unprivileged[link access_context/unprivileged.md] + +### 出力 +``` +unchecked: + secret + visible +unprivileged: + visible +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/current.md b/reference/meta/access_context/current.md new file mode 100644 index 0000000000..3f4d36227f --- /dev/null +++ b/reference/meta/access_context/current.md @@ -0,0 +1,79 @@ +# current +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +static consteval access_context current() noexcept; +``` + +## 概要 +呼び出し元のスコープにおけるアクセス権に従うアクセスコンテキストを返す。 + +呼び出し元がクラスのメンバ関数やフレンド関数内であれば、そのクラスの`private`/`protected`メンバにもアクセス可能なコンテキストとなる。 + + +## 戻り値 +呼び出し元のアクセス権を反映した`access_context`オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +class C { + int secret = 42; +public: + int visible = 1; + + static void inspect() { + // current()はC内部からの呼び出しなのでprivateメンバも見える + std::println("C内部から見えるメンバ:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^C, std::meta::access_context::current())) { + std::println(" {}", std::meta::identifier_of(m)); + } + } +}; + +int main() { + C::inspect(); + + // current()はmain関数からの呼び出しなのでpublicのみ + std::println("外部から見えるメンバ:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^C, std::meta::access_context::current())) { + std::println(" {}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::access_context::current()[color ff0000] +* std::meta::nonstatic_data_members_of[link ../nonstatic_data_members_of.md] +* std::meta::identifier_of[link ../identifier_of.md] + +### 出力 +``` +C内部から見えるメンバ: + secret + visible +外部から見えるメンバ: + visible +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/designating_class.md b/reference/meta/access_context/designating_class.md new file mode 100644 index 0000000000..358d631767 --- /dev/null +++ b/reference/meta/access_context/designating_class.md @@ -0,0 +1,64 @@ +# designating_class +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +consteval info designating_class() const; +``` +* info[link ../info.md] + +## 概要 +アクセスコンテキストの指定クラス (designating class) のリフレクションを返す。 + +`via()`で派生クラスを経由するアクセスコンテキストを作った場合、`designating_class()`はその派生クラスを返す。 + + +## 戻り値 +このアクセスコンテキストにおいて、メンバアクセスの対象となるクラスのリフレクションを返す。 + + +## 例 +```cpp example +#include +#include + +class Base { +protected: + int prot; +public: + int pub; +}; + +class Derived : public Base {}; + +int main() { + constexpr auto ctx = std::meta::access_context::current().via(^^Derived); + std::println("designating class: {}", + std::meta::display_string_of(ctx.designating_class())); +} +``` +* designating_class()[color ff0000] +* std::meta::access_context::current[link current.md] +* via[link via.md] +* std::meta::display_string_of[link ../display_string_of.md] + +#### 出力例 +``` +designating class: Derived +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/scope.md b/reference/meta/access_context/scope.md new file mode 100644 index 0000000000..974d482d21 --- /dev/null +++ b/reference/meta/access_context/scope.md @@ -0,0 +1,62 @@ +# scope +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +consteval info scope() const; +``` +* info[link ../info.md] + +## 概要 +アクセスコンテキストのスコープのリフレクションを返す。 + + +## 戻り値 +このアクセスコンテキストが関連付けられているスコープのリフレクションを返す。 + + +## 例 +```cpp example +#include +#include + +class C { + int secret; +public: + int visible; + + static void inspect() { + constexpr auto ctx = std::meta::access_context::current(); + // C内部からcurrent()を呼んだので、スコープはC + std::println("scope: {}", std::meta::display_string_of(ctx.scope())); + } +}; + +int main() { + C::inspect(); +} +``` +* scope()[color ff0000] +* std::meta::access_context::current[link current.md] +* std::meta::display_string_of[link ../display_string_of.md] + +#### 出力例 +``` +scope: C +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/unchecked.md b/reference/meta/access_context/unchecked.md new file mode 100644 index 0000000000..25538d4f18 --- /dev/null +++ b/reference/meta/access_context/unchecked.md @@ -0,0 +1,67 @@ +# unchecked +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +static consteval access_context unchecked() noexcept; +``` + +## 概要 +アクセス制限なしですべてのメンバにアクセス可能なアクセスコンテキストを返す。 + +`private`/`protected`メンバを含むすべてのメンバが取得可能となる。シリアライズやデバッグなど、アクセス制御を無視してすべてのメンバを列挙する必要がある場面で使用する。 + + +## 戻り値 +すべてのメンバにアクセス可能な`access_context`オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +class C { + int secret = 42; +protected: + int prot = 2; +public: + int visible = 1; +}; + +int main() { + std::println("全メンバ:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^C, std::meta::access_context::unchecked())) { + std::println(" {}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::access_context::unchecked()[color ff0000] +* std::meta::nonstatic_data_members_of[link ../nonstatic_data_members_of.md] +* std::meta::identifier_of[link ../identifier_of.md] + +### 出力 +``` +全メンバ: + secret + prot + visible +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/unprivileged.md b/reference/meta/access_context/unprivileged.md new file mode 100644 index 0000000000..bd144d304d --- /dev/null +++ b/reference/meta/access_context/unprivileged.md @@ -0,0 +1,63 @@ +# unprivileged +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +static consteval access_context unprivileged() noexcept; +``` + +## 概要 +`public`メンバのみにアクセス可能なアクセスコンテキストを返す。 + +呼び出し元のスコープに関係なく、常に`public`メンバのみが取得可能となる。 + + +## 戻り値 +`public`メンバのみにアクセス可能な`access_context`オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +class C { + int secret = 42; +public: + int visible = 1; +}; + +int main() { + std::println("publicメンバ:"); + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^C, std::meta::access_context::unprivileged())) { + std::println(" {}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::access_context::unprivileged()[color ff0000] +* std::meta::nonstatic_data_members_of[link ../nonstatic_data_members_of.md] +* std::meta::identifier_of[link ../identifier_of.md] + +### 出力 +``` +publicメンバ: + visible +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/access_context/via.md b/reference/meta/access_context/via.md new file mode 100644 index 0000000000..5b163c4f8e --- /dev/null +++ b/reference/meta/access_context/via.md @@ -0,0 +1,63 @@ +# via +* meta[meta header] +* std::meta[meta namespace] +* access_context[meta class] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +consteval access_context via(info cls) const; +``` +* info[link ../info.md] + +## 概要 +指定したクラスを経由したアクセスコンテキストを返す。 + +継承階層において、派生クラス経由で基底クラスのメンバにアクセスする場合のアクセス制御を再現するために使用する。 + + +## 戻り値 +`cls`が表すクラスを経由した新しい`access_context`オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +class Base { +protected: + int prot = 1; +public: + int pub = 2; +}; + +class Derived : public Base {}; + +int main() { + // Derived経由でBaseのメンバにアクセス + constexpr auto ctx = std::meta::access_context::current().via(^^Derived); + constexpr auto members = std::meta::nonstatic_data_members_of(^^Base, ctx); + std::println("Derived経由で見えるメンバ数: {}", members.size()); +} +``` +* via[color ff0000] +* std::meta::nonstatic_data_members_of[link ../nonstatic_data_members_of.md] + +### 出力 +``` +Derived経由で見えるメンバ数: 2 +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_const.md b/reference/meta/add_const.md new file mode 100644 index 0000000000..9c9feab939 --- /dev/null +++ b/reference/meta/add_const.md @@ -0,0 +1,54 @@ +# add_const +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_const(info type); +} +``` +* info[link info.md] + +## 概要 +型に`const`修飾を付加する。[`std::add_const`](/reference/type_traits/add_const.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_const`](/reference/type_traits/add_const.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_const(^^int) == ^^const int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_const`](/reference/type_traits/add_const.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_cv.md b/reference/meta/add_cv.md new file mode 100644 index 0000000000..b867f7f32a --- /dev/null +++ b/reference/meta/add_cv.md @@ -0,0 +1,55 @@ +# add_cv +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_cv(info type); +} +``` +* info[link info.md] + +## 概要 +型にCV修飾(`const`と`volatile`)を付加する。[`std::add_cv`](/reference/type_traits/add_cv.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_cv`](/reference/type_traits/add_cv.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_cv(^^int) == ^^const volatile int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_cv`](/reference/type_traits/add_cv.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_lvalue_reference.md b/reference/meta/add_lvalue_reference.md new file mode 100644 index 0000000000..feb4a55ff4 --- /dev/null +++ b/reference/meta/add_lvalue_reference.md @@ -0,0 +1,55 @@ +# add_lvalue_reference +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_lvalue_reference(info type); +} +``` +* info[link info.md] + +## 概要 +型に左辺値参照を付加する。[`std::add_lvalue_reference`](/reference/type_traits/add_lvalue_reference.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_lvalue_reference`](/reference/type_traits/add_lvalue_reference.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_lvalue_reference(^^int) == ^^int&); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_lvalue_reference`](/reference/type_traits/add_lvalue_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_pointer.md b/reference/meta/add_pointer.md new file mode 100644 index 0000000000..4eb47ff35d --- /dev/null +++ b/reference/meta/add_pointer.md @@ -0,0 +1,55 @@ +# add_pointer +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_pointer(info type); +} +``` +* info[link info.md] + +## 概要 +型にポインタを付加する。[`std::add_pointer`](/reference/type_traits/add_pointer.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_pointer`](/reference/type_traits/add_pointer.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_pointer(^^int) == ^^int*); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_pointer`](/reference/type_traits/add_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_rvalue_reference.md b/reference/meta/add_rvalue_reference.md new file mode 100644 index 0000000000..473273802f --- /dev/null +++ b/reference/meta/add_rvalue_reference.md @@ -0,0 +1,55 @@ +# add_rvalue_reference +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_rvalue_reference(info type); +} +``` +* info[link info.md] + +## 概要 +型に右辺値参照を付加する。[`std::add_rvalue_reference`](/reference/type_traits/add_rvalue_reference.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_rvalue_reference`](/reference/type_traits/add_rvalue_reference.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_rvalue_reference(^^int) == ^^int&&); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_rvalue_reference`](/reference/type_traits/add_rvalue_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/add_volatile.md b/reference/meta/add_volatile.md new file mode 100644 index 0000000000..983c5083cf --- /dev/null +++ b/reference/meta/add_volatile.md @@ -0,0 +1,55 @@ +# add_volatile +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info add_volatile(info type); +} +``` +* info[link info.md] + +## 概要 +型に`volatile`修飾を付加する。[`std::add_volatile`](/reference/type_traits/add_volatile.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::add_volatile`](/reference/type_traits/add_volatile.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::add_volatile(^^int) == ^^volatile int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::add_volatile`](/reference/type_traits/add_volatile.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/alignment_of.md b/reference/meta/alignment_of.md new file mode 100644 index 0000000000..a5314c0e5c --- /dev/null +++ b/reference/meta/alignment_of.md @@ -0,0 +1,52 @@ +# alignment_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval size_t alignment_of(info r); +} +``` +* info[link info.md] + +## 概要 +型またはデータメンバのアライメントを取得する。 + + +## 戻り値 +`r`が型を表す場合は`alignof`相当の値を、非静的データメンバを表す場合はそのメンバのアライメントを返す。 + + +## 例外 +`r`が型または非静的データメンバを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::alignment_of(^^int) == alignof(int)); + static_assert(std::meta::alignment_of(^^double) == alignof(double)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/annotations_of.md b/reference/meta/annotations_of.md new file mode 100644 index 0000000000..2c4f9cca14 --- /dev/null +++ b/reference/meta/annotations_of.md @@ -0,0 +1,77 @@ +# annotations_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector annotations_of(info item); +} +``` +* info[link info.md] + +## 概要 +宣言に付加されたすべてのアノテーションのリフレクションを取得する。 + + +## 戻り値 +`item`に付加されたすべてのアノテーションのリフレクションを格納した[`std::vector`](/reference/vector/vector.md)オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +struct Label { const char* text; }; + +struct [[=Label{std::define_static_string("my struct")}, =42]] S {}; + +int main() { + constexpr auto annots = std::meta::annotations_of(^^S); + std::println("アノテーション数: {}", annots.size()); + + template for (constexpr auto a : annots) { + // アノテーションの型名を出力 + std::println(" 型: {}", std::meta::display_string_of(std::meta::type_of(a))); + + // 型ごとに値を取り出して出力 + if constexpr (std::meta::type_of(a) == ^^Label) { + std::println(" 値: {}", [:a:].text); + } else if constexpr (std::meta::type_of(a) == ^^int) { + std::println(" 値: {}", [:a:]); + } + } +} +``` +* std::meta::display_string_of[link display_string_of.md] +* std::meta::type_of[link type_of.md] + +### 出力 +``` +アノテーション数: 2 + 型: Label + 値: my struct + 型: int + 値: 42 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`annotations_of_with_type`](annotations_of_with_type.md) +- [`is_annotation`](is_annotation.md) + + +## 参照 +- [P3394R4 Annotations for Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3394r4.html) diff --git a/reference/meta/annotations_of_with_type.md b/reference/meta/annotations_of_with_type.md new file mode 100644 index 0000000000..8c4be8f71e --- /dev/null +++ b/reference/meta/annotations_of_with_type.md @@ -0,0 +1,63 @@ +# annotations_of_with_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector annotations_of_with_type(info item, info type); +} +``` +* info[link info.md] + +## 概要 +宣言に付加された指定した型のアノテーションのみを取得する。 + + +## 戻り値 +`item`に付加されたアノテーションのうち、型が`type`に一致するもののリフレクションを格納した[`std::vector`](/reference/vector/vector.md)オブジェクトを返す。 + + +## 例 +```cpp example +#include +#include + +struct Name { const char* value; }; + +struct [[=Name{std::define_static_string("点")}, =42]] Point { + [[=Name{std::define_static_string("x座標")}]] int x; + [[=Name{std::define_static_string("y座標")}]] int y; +}; + +int main() { + constexpr auto annots = std::meta::annotations_of_with_type(^^Point, ^^Name); + static_assert(annots.size() == 1); + std::println("{}", [:annots[0]:].value); +} +``` + +### 出力 +``` +点 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`annotations_of`](annotations_of.md) +- [`is_annotation`](is_annotation.md) + + +## 参照 +- [P3394R4 Annotations for Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3394r4.html) diff --git a/reference/meta/bases_of.md b/reference/meta/bases_of.md new file mode 100644 index 0000000000..14fdfeab6e --- /dev/null +++ b/reference/meta/bases_of.md @@ -0,0 +1,75 @@ +# bases_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector bases_of(info type, access_context ctx); +} +``` +* info[link info.md] + +## 概要 +クラスの直接基底クラスのリフレクションを取得する。 + + +## 戻り値 +`type`が完全型のクラスを表す場合、アクセスコンテキスト`ctx`でアクセス可能な直接基底クラス関係のリフレクションを格納した[`std::vector`](/reference/vector/vector.md)オブジェクトを返す。 + + +## 例外 +`r`が完全型のクラスを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 備考 +- C++では多重継承ができるため、基底クラスは複数存在する可能性がある + + +## 例 +```cpp example +#include +#include + +struct A {}; +struct B {}; +struct C : A, B {}; + +int main() { + // クラスCの直接基底クラスを取得して出力 + template for (constexpr auto b : + std::meta::bases_of(^^C, std::meta::access_context::unchecked())) { + std::println("{}", std::meta::display_string_of(std::meta::type_of(b))); + } +} +``` +* std::meta::display_string_of[link display_string_of.md] +* std::meta::type_of[link type_of.md] + +### 出力 +``` +A +B +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`members_of`](members_of.md) +- [`subobjects_of`](subobjects_of.md) +- [`is_base`](is_base.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3293R3 Splicing a base class subobject](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html) diff --git a/reference/meta/bit_size_of.md b/reference/meta/bit_size_of.md new file mode 100644 index 0000000000..5d4fcf2ff6 --- /dev/null +++ b/reference/meta/bit_size_of.md @@ -0,0 +1,63 @@ +# bit_size_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::size_t bit_size_of(info r); +} +``` +* info[link info.md] + +## 概要 +ビットフィールドのビットサイズを取得する。 + + +## 戻り値 +`r`がビットフィールドを表す場合、そのビット幅を返す。 + + +## 例外 +`r`がビットフィールドを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Flags { + unsigned a : 1; + unsigned b : 3; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^Flags, std::meta::access_context::unchecked()); + static_assert(std::meta::bit_size_of(members[0]) == 1); + static_assert(std::meta::bit_size_of(members[1]) == 3); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::meta::is_bit_field`](is_bit_field.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/can_substitute.md b/reference/meta/can_substitute.md new file mode 100644 index 0000000000..4b86360048 --- /dev/null +++ b/reference/meta/can_substitute.md @@ -0,0 +1,58 @@ +# can_substitute +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool can_substitute(info templ, R&& arguments); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +テンプレートにテンプレート引数を置換可能かを判定する。 + + +## 戻り値 +テンプレート`templ`に`arguments`を置換した結果が妥当である場合に`true`を返す。そうでなければ`false`を返す。 + + +## 例外 +`templ`がテンプレートを表さない場合、または`arguments`の要素がテンプレート引数として使用可能な構成要素を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::can_substitute(^^std::vector, {^^int})); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`substitute`](substitute.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/common_reference.md b/reference/meta/common_reference.md new file mode 100644 index 0000000000..19afb49bd7 --- /dev/null +++ b/reference/meta/common_reference.md @@ -0,0 +1,57 @@ +# common_reference +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval info common_reference(R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +複数の型の共通参照型を求める。[`std::common_reference`](/reference/type_traits/common_reference.md)に対応する。 + + +## 戻り値 +`type_args`の各要素が表す型に対して[`std::common_reference`](/reference/type_traits/common_reference.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::common_reference({^^int&, ^^const int&}) == ^^const int&); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::common_reference`](/reference/type_traits/common_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/common_type.md b/reference/meta/common_type.md new file mode 100644 index 0000000000..2f00217c99 --- /dev/null +++ b/reference/meta/common_type.md @@ -0,0 +1,57 @@ +# common_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval info common_type(R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +複数の型の共通型を求める。[`std::common_type`](/reference/type_traits/common_type.md)に対応する。 + + +## 戻り値 +`type_args`の各要素が表す型に対して[`std::common_type`](/reference/type_traits/common_type.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::common_type({^^int, ^^double}) == ^^double); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::common_type`](/reference/type_traits/common_type.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/constant_of.md b/reference/meta/constant_of.md new file mode 100644 index 0000000000..c05bd146bf --- /dev/null +++ b/reference/meta/constant_of.md @@ -0,0 +1,55 @@ +# constant_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info constant_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションが表す定数のリフレクションを取得する。 + + +## 戻り値 +`r`が定数式を表す場合、その定数値のリフレクションを返す。 + + +## 例外 +`r`のスプライスが有効なスプライス式でない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +constexpr int value = 42; + +int main() { + constexpr auto c = std::meta::constant_of(^^value); + static_assert(std::meta::extract(c) == 42); +} +``` +* std::meta::extract[link extract.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/data_member_options.md b/reference/meta/data_member_options.md new file mode 100644 index 0000000000..0fa31c22eb --- /dev/null +++ b/reference/meta/data_member_options.md @@ -0,0 +1,50 @@ +# data_member_options +* meta[meta header] +* std::meta[meta namespace] +* class[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + struct data_member_options { + struct name-type; // 説明専用 + optional name; + optional alignment; + optional bit_width; + bool no_unique_address = false; + }; +} +``` + +## 概要 +`data_member_options`は、[`data_member_spec()`](data_member_spec.md)でデータメンバの仕様を作成する際に、メンバの名前やアライメント、ビット幅などのオプションを指定するためのクラスである。 + +consteval-only型であり、実行時には存在できない。 + +## メンバ変数 + +| 名前 | 説明 | +|------|------| +| `name` | メンバの名前。`string_view`または`u8string_view`を受け取る | +| `alignment` | アライメントの指定 | +| `bit_width` | ビットフィールドのビット幅 | +| `no_unique_address` | `[[no_unique_address]]`属性を付加するか | + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`data_member_spec`](data_member_spec.md) +- [`define_aggregate`](define_aggregate.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/data_member_spec.md b/reference/meta/data_member_spec.md new file mode 100644 index 0000000000..792e129ef0 --- /dev/null +++ b/reference/meta/data_member_spec.md @@ -0,0 +1,72 @@ +# data_member_spec +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info data_member_spec(info type, data_member_options options); +} +``` +* info[link info.md] +* data_member_options[link data_member_options.md] + +## 概要 +データメンバの仕様を作成する。[`define_aggregate()`](define_aggregate.md)で使用するデータメンバの仕様を表すリフレクションを返す。 + + +## 戻り値 +指定された型`type`とオプション`options`に基づくデータメンバの仕様を表すリフレクションを返す。 + + +## 例外 +以下のいずれかの場合、[`std::meta::exception`](exception.md)例外を送出する: + +- `type`がオブジェクト型または参照型を表さない場合 +- `options.name`に値があり、有効な識別子でない場合 +- `options.name`に値がなく、`options.bit_width`にも値がない場合 + + +## 例 +```cpp example +#include + +struct S; + +consteval { + std::meta::define_aggregate(^^S, { + std::meta::data_member_spec(^^int, {.name = "x"}), + std::meta::data_member_spec(^^double, {.name = "y"}) + }); +} + +int main() { + S s{1, 2.0}; + static_assert(std::meta::is_data_member_spec( + std::meta::data_member_spec(^^int, {.name = "z"}))); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`data_member_options`](data_member_options.md) +- [`define_aggregate`](define_aggregate.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/dealias.md b/reference/meta/dealias.md new file mode 100644 index 0000000000..d365f93514 --- /dev/null +++ b/reference/meta/dealias.md @@ -0,0 +1,54 @@ +# dealias +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info dealias(info r); +} +``` +* info[link info.md] + +## 概要 +エイリアスを解決して元のエンティティのリフレクションを取得する。 + + +## 戻り値 +`r`が型エイリアスまたは名前空間エイリアスを表す場合、エイリアス先のリフレクションを返す。エイリアスでなければ`r`をそのまま返す。 + + +## 例外 +`r`がエンティティを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +using MyInt = int; + +int main() { + static_assert(^^MyInt != ^^int); // 型の別名は区別される + static_assert(std::meta::dealias(^^MyInt) == ^^int); // dealias()で元の型を取得 +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/decay.md b/reference/meta/decay.md new file mode 100644 index 0000000000..d195526d43 --- /dev/null +++ b/reference/meta/decay.md @@ -0,0 +1,55 @@ +# decay +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info decay(info type); +} +``` +* info[link info.md] + +## 概要 +型に対して、配列からポインタ、関数から関数ポインタへの暗黙変換を適用する。[`std::decay`](/reference/type_traits/decay.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::decay`](/reference/type_traits/decay.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::decay(^^int[3]) == ^^int*); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::decay`](/reference/type_traits/decay.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/define_aggregate.md b/reference/meta/define_aggregate.md new file mode 100644 index 0000000000..51dc66db35 --- /dev/null +++ b/reference/meta/define_aggregate.md @@ -0,0 +1,70 @@ +# define_aggregate +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval info define_aggregate(info type_class, R&& members); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +不完全なクラス型を、指定されたデータメンバを持つ集成体として定義する。 + + +## 戻り値 +不完全なクラス型`type_class`を、`members`で指定されたデータメンバを持つ集成体として定義し、完全型となったクラスのリフレクションを返す。 + + +## 備考 +`type_class`は不完全なクラス型を表すリフレクションでなければならない。`members`の各要素は[`is_data_member_spec()`](is_data_member_spec.md)が`true`を返すリフレクションでなければならない。 + + +## 例 +```cpp example +#include +#include + +struct MyStruct; + +consteval { + std::meta::define_aggregate(^^MyStruct, { + std::meta::data_member_spec(^^int, {.name = "id"}), + std::meta::data_member_spec(^^double, {.name = "value"}) + }); +} + +int main() { + MyStruct s{42, 3.14}; + std::println("id={}, value={}", s.id, s.value); +} +``` + +### 出力 +``` +id=42, value=3.14 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`data_member_spec`](data_member_spec.md) +- [`data_member_options`](data_member_options.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/define_static_array.md b/reference/meta/define_static_array.md new file mode 100644 index 0000000000..80a5a63230 --- /dev/null +++ b/reference/meta/define_static_array.md @@ -0,0 +1,62 @@ +# define_static_array +* meta[meta header] +* std[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + template + consteval std::span> define_static_array(R&& r); +} +``` + +## 概要 +コンパイル時に計算した配列を静的ストレージに配置し、その範囲を参照する[`span`](/reference/span/span.md)を返す。 + + +## 戻り値 +`r`の要素をコピーした静的ストレージ上の配列を参照する`std::span`を返す。 + + +## 例 +```cpp example +#include +#include +#include + +int main() { + constexpr auto arr = std::define_static_array(std::array{1, 2, 3, 4, 5}); + for (auto v : arr) { + std::println("{}", v); + } +} +``` + +### 出力 +``` +1 +2 +3 +4 +5 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_string`](define_static_string.md) +- [`define_static_object`](define_static_object.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/define_static_object.md b/reference/meta/define_static_object.md new file mode 100644 index 0000000000..af2d00009e --- /dev/null +++ b/reference/meta/define_static_object.md @@ -0,0 +1,60 @@ +# define_static_object +* meta[meta header] +* std[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + template + consteval const remove_cvref_t* define_static_object(T&& t); +} +``` + +## 概要 +コンパイル時に計算したオブジェクトを静的ストレージに配置し、そのポインタを返す。 + + +## 戻り値 +`t`のコピーを保持する静的ストレージ上のオブジェクトへのポインタを返す。 + + +## 例 +```cpp example +#include +#include + +struct Config { + int width; + int height; +}; + +int main() { + constexpr auto* p = std::define_static_object(Config{1920, 1080}); + std::println("{}x{}", p->width, p->height); +} +``` + +### 出力 +``` +1920x1080 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_string`](define_static_string.md) +- [`define_static_array`](define_static_array.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/define_static_string.md b/reference/meta/define_static_string.md new file mode 100644 index 0000000000..972ae757e3 --- /dev/null +++ b/reference/meta/define_static_string.md @@ -0,0 +1,71 @@ +# define_static_string +* meta[meta header] +* std[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + template + consteval const ranges::range_value_t* define_static_string(R&& r); +} +``` + +## 概要 +コンパイル時に計算した文字列を静的ストレージに配置し、ヌル終端された文字列へのポインタを返す。 + + +## 戻り値 +`r`の要素をコピーした静的ストレージ上のヌル終端文字列へのポインタを返す。 + + +## 例 +```cpp example +#include +#include +#include + +template + requires std::is_enum_v +constexpr std::string_view to_string(E value) { + template for (constexpr auto e : std::meta::enumerators_of(^^E)) { + if (value == [:e:]) { + return std::define_static_string(std::meta::identifier_of(e)); + } + } + return ""; +} + +enum class Fruit { apple, banana, cherry }; + +int main() { + std::println("{}", to_string(Fruit::banana)); +} +``` +* std::is_enum_v[link /reference/type_traits/is_enum.md] +* std::meta::enumerators_of[link enumerators_of.md] +* std::meta::identifier_of[link identifier_of.md] + +### 出力 +``` +banana +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_array`](define_static_array.md) +- [`define_static_object`](define_static_object.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/display_string_of.md b/reference/meta/display_string_of.md new file mode 100644 index 0000000000..4918383726 --- /dev/null +++ b/reference/meta/display_string_of.md @@ -0,0 +1,51 @@ +# display_string_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] +* u8display_string_of[meta alias] + +```cpp +namespace std::meta { + consteval string_view display_string_of(info r); + consteval u8string_view u8display_string_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションの表示用文字列を取得する。 + + +## 戻り値 +`r`の人間可読な表示文字列を返す。結果は実装定義である。 + + +## 例 +```cpp example +#include +#include + +int main() { + std::println("{}", std::meta::display_string_of(^^int)); + std::println("{}", std::meta::display_string_of(^^std::vector)); +} +``` + +#### 出力例 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/enumerators_of.md b/reference/meta/enumerators_of.md new file mode 100644 index 0000000000..51c4f8ca79 --- /dev/null +++ b/reference/meta/enumerators_of.md @@ -0,0 +1,59 @@ +# enumerators_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector enumerators_of(info type_enum); +} +``` +* info[link info.md] + +## 概要 +列挙型の列挙子のリフレクションを取得する。 + + +## 戻り値 +`type_enum`が列挙型を表す場合、そのすべての列挙子のリフレクションを宣言順に格納した`std::vector`オブジェクトを返す。 + + +## 例外 +`r`が列挙型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +enum class Color { red, green, blue }; + +int main() { + template for (constexpr auto e : std::meta::enumerators_of(^^Color)) { + std::println("{}", std::meta::identifier_of(e)); + } +} +``` + +### 出力 +``` +red +green +blue +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/exception.md b/reference/meta/exception.md new file mode 100644 index 0000000000..e4271ebd6b --- /dev/null +++ b/reference/meta/exception.md @@ -0,0 +1,53 @@ +# exception +* meta[meta header] +* std::meta[meta namespace] +* class[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + class exception : public std::exception { + public: + exception(u8string_view msg, info from, std::source_location where = std::source_location::current()); + const char* what() const noexcept override; + const char8_t* u8what() const noexcept; + consteval info from() const; + consteval std::source_location where() const; + }; +} +``` +* info[link info.md] +* current()[link /reference/source_location/source_location/current.md] + +## 概要 +`exception`は、リフレクションのメタ関数がエラーを報告するために送出する例外クラスである。[`std::exception`](/reference/exception/exception.md)から派生する。 + +定数評価中にのみ送出・捕捉されるため、実行時のオーバーヘッドはない。 + +## メンバ関数 + +| 名前 | 説明 | +|------|------| +| `what()` | エラーメッセージを通常のエンコーディングで取得 | +| `u8what()` | エラーメッセージをUTF-8で取得 | +| `from()` | 送出元のメタ関数のリフレクションを取得 | +| `where()` | エラーが発生したソース位置を取得 | + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [C++26 定数評価での例外送出を許可](/lang/cpp26/allowing_exception_throwing_in_constant-evaluation.md) +- [`std::exception`](/reference/exception/exception.md) + + +## 参照 +- [P3560R2 Error Handling in Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3560r2.html) diff --git a/reference/meta/extent.md b/reference/meta/extent.md new file mode 100644 index 0000000000..a146b88a9a --- /dev/null +++ b/reference/meta/extent.md @@ -0,0 +1,58 @@ +# extent +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::size_t extent(info type, unsigned int i = 0); +} +``` +* info[link info.md] + +## 概要 +配列型の指定次元の要素数を取得する。[`std::extent`](/reference/type_traits/extent.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して、`i`番目の次元の[`std::extent`](/reference/type_traits/extent.md)相当の値を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::extent(^^int[3][4], 0) == 3); + static_assert(std::meta::extent(^^int[3][4], 1) == 4); + static_assert(std::meta::extent(^^int[3]) == 3); +} +``` +* std::meta::extent[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`rank`](rank.md) +- [`std::extent`](/reference/type_traits/extent.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/extract.md b/reference/meta/extract.md new file mode 100644 index 0000000000..a5625f2842 --- /dev/null +++ b/reference/meta/extract.md @@ -0,0 +1,63 @@ +# extract +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval T extract(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションから値を抽出する。 + + +## 戻り値 +`r`が型`T`の値を表す場合、その値を返す。 + + +## 例外 +`r`が型`T`の値を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +enum class Color { red = 1, green = 2, blue = 3 }; + +int main() { + constexpr auto r = std::meta::reflect_constant(42); + static_assert(std::meta::extract(r) == 42); + + constexpr auto c = std::meta::reflect_constant(Color::green); + static_assert(std::meta::extract(c) == Color::green); +} +``` +* std::meta::reflect_constant[link reflect_constant.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`reflect_constant`](reflect_constant.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_automatic_storage_duration.md b/reference/meta/has_automatic_storage_duration.md new file mode 100644 index 0000000000..bdcc7bb2f7 --- /dev/null +++ b/reference/meta/has_automatic_storage_duration.md @@ -0,0 +1,51 @@ +# has_automatic_storage_duration +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_automatic_storage_duration(info r); +} +``` +* info[link info.md] + +## 概要 +自動記憶域期間を持つかを判定する。 + + +## 戻り値 +`r`が自動記憶域期間を持つ変数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int global; + +int main() { + int local; + static_assert(std::meta::has_automatic_storage_duration(^^local)); + static_assert(!std::meta::has_automatic_storage_duration(^^global)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_c_language_linkage.md b/reference/meta/has_c_language_linkage.md new file mode 100644 index 0000000000..94c5a80a4b --- /dev/null +++ b/reference/meta/has_c_language_linkage.md @@ -0,0 +1,53 @@ +# has_c_language_linkage +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_c_language_linkage(info r); +} +``` +* info[link info.md] + +## 概要 +C言語リンケージを持つかを判定する。 + + +## 戻り値 +`r`がC言語リンケージ(`extern "C"`)を持つエンティティを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +extern "C" void c_func(); +void cpp_func(); +extern "C" int c_var; + +int main() { + static_assert(std::meta::has_c_language_linkage(^^c_func)); + static_assert(!std::meta::has_c_language_linkage(^^cpp_func)); + static_assert(std::meta::has_c_language_linkage(^^c_var)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_default_argument.md b/reference/meta/has_default_argument.md new file mode 100644 index 0000000000..e999bc5ea2 --- /dev/null +++ b/reference/meta/has_default_argument.md @@ -0,0 +1,52 @@ +# has_default_argument +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_default_argument(info r); +} +``` +* info[link info.md] + +## 概要 +関数パラメータがデフォルト引数を持つかを判定する。 + + +## 戻り値 +`r`が関数パラメータを表し、そのパラメータが到達可能な宣言のいずれかでデフォルト引数を持つ場合に`true`を返す。そうでなければ`false`を返す。 + + +## 例 +```cpp example +#include + +void func(int x, int y = 10); + +int main() { + constexpr auto params = std::meta::parameters_of(^^func); + static_assert(!std::meta::has_default_argument(params[0])); // x + static_assert(std::meta::has_default_argument(params[1])); // y = 10 +} +``` +* std::meta::parameters_of[link parameters_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/has_default_member_initializer.md b/reference/meta/has_default_member_initializer.md new file mode 100644 index 0000000000..ee5dee3772 --- /dev/null +++ b/reference/meta/has_default_member_initializer.md @@ -0,0 +1,53 @@ +# has_default_member_initializer +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_default_member_initializer(info r); +} +``` +* info[link info.md] + +## 概要 +デフォルトメンバ初期化子を持つかを判定する。 + + +## 戻り値 +`r`がデフォルトメンバ初期化子を持つ非静的データメンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int x; + int y = 42; +}; + +int main() { + static_assert(!std::meta::has_default_member_initializer(^^S::x)); + static_assert(std::meta::has_default_member_initializer(^^S::y)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_ellipsis_parameter.md b/reference/meta/has_ellipsis_parameter.md new file mode 100644 index 0000000000..bfd475b87a --- /dev/null +++ b/reference/meta/has_ellipsis_parameter.md @@ -0,0 +1,51 @@ +# has_ellipsis_parameter +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_ellipsis_parameter(info r); +} +``` +* info[link info.md] + +## 概要 +関数が可変長引数(`...`)を持つかを判定する。 + + +## 戻り値 +`r`が関数または関数型を表し、そのパラメータリストが省略記号(`...`)で終わる場合に`true`を返す。そうでなければ`false`を返す。 + + +## 例 +```cpp example +#include + +int printf(const char* fmt, ...); +void normal(int x); + +int main() { + static_assert(std::meta::has_ellipsis_parameter(^^printf)); + static_assert(!std::meta::has_ellipsis_parameter(^^normal)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/has_external_linkage.md b/reference/meta/has_external_linkage.md new file mode 100644 index 0000000000..47ff253c24 --- /dev/null +++ b/reference/meta/has_external_linkage.md @@ -0,0 +1,53 @@ +# has_external_linkage +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_external_linkage(info r); +} +``` +* info[link info.md] + +## 概要 +外部リンケージを持つかを判定する。 + + +## 戻り値 +`r`が外部リンケージを持つエンティティを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int global_var; // 外部リンケージ +static int internal_var; // 内部リンケージ +namespace { int anon_var; } // 内部リンケージ + +int main() { + static_assert(std::meta::has_external_linkage(^^global_var)); + static_assert(!std::meta::has_external_linkage(^^internal_var)); + static_assert(!std::meta::has_external_linkage(^^anon_var)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_identifier.md b/reference/meta/has_identifier.md new file mode 100644 index 0000000000..eaa7886cf8 --- /dev/null +++ b/reference/meta/has_identifier.md @@ -0,0 +1,53 @@ +# has_identifier +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_identifier(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションが識別子を持つかどうかを判定する。 + + +## 戻り値 +`r`が識別子を持つ場合は`true`、そうでなければ`false`を返す。名前のない関数パラメータや、異なる宣言間でパラメータ名が一致しない場合は`false`となる。 + + +## 例 +```cpp example +#include + +void func(int x, int); + +int main() { + constexpr auto params = std::meta::parameters_of(^^func); + static_assert(std::meta::has_identifier(params[0])); // "x"という名前がある + static_assert(!std::meta::has_identifier(params[1])); // 名前がない +} +``` +* std::meta::parameters_of[link parameters_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/has_inaccessible_bases.md b/reference/meta/has_inaccessible_bases.md new file mode 100644 index 0000000000..ff653a227b --- /dev/null +++ b/reference/meta/has_inaccessible_bases.md @@ -0,0 +1,57 @@ +# has_inaccessible_bases +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_inaccessible_bases(info r, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスにアクセス不可能な基底クラスがあるかを判定する。 + + +## 戻り値 +指定したアクセスコンテキストでアクセスできない基底クラスが存在する場合に`true`を返す。 + + +## 例 +```cpp example +#include + +class C { + int secret; +public: + int visible; +}; + +int main() { + constexpr auto ctx = std::meta::access_context::unprivileged(); + static_assert(std::meta::has_inaccessible_bases(^^C, ctx)); +} +``` +* std::meta::access_context[link access_context.md] +* unprivileged[link access_context/unprivileged.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_inaccessible_nonstatic_data_members.md b/reference/meta/has_inaccessible_nonstatic_data_members.md new file mode 100644 index 0000000000..f8a6ae2618 --- /dev/null +++ b/reference/meta/has_inaccessible_nonstatic_data_members.md @@ -0,0 +1,57 @@ +# has_inaccessible_nonstatic_data_members +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_inaccessible_nonstatic_data_members(info r, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスにアクセス不可能な非静的データメンバがあるかを判定する。 + + +## 戻り値 +指定したアクセスコンテキストでアクセスできない非静的データメンバが存在する場合に`true`を返す。 + + +## 例 +```cpp example +#include + +class C { + int secret; +public: + int visible; +}; + +int main() { + constexpr auto ctx = std::meta::access_context::unprivileged(); + static_assert(std::meta::has_inaccessible_nonstatic_data_members(^^C, ctx)); +} +``` +* std::meta::access_context[link access_context.md] +* unprivileged[link access_context/unprivileged.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_internal_linkage.md b/reference/meta/has_internal_linkage.md new file mode 100644 index 0000000000..de19fe0d02 --- /dev/null +++ b/reference/meta/has_internal_linkage.md @@ -0,0 +1,51 @@ +# has_internal_linkage +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_internal_linkage(info r); +} +``` +* info[link info.md] + +## 概要 +内部リンケージを持つかを判定する。 + + +## 戻り値 +`r`が内部リンケージを持つエンティティを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +static int internal_var; +int external_var; + +int main() { + static_assert(std::meta::has_internal_linkage(^^internal_var)); + static_assert(!std::meta::has_internal_linkage(^^external_var)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_linkage.md b/reference/meta/has_linkage.md new file mode 100644 index 0000000000..2587bc89a2 --- /dev/null +++ b/reference/meta/has_linkage.md @@ -0,0 +1,53 @@ +# has_linkage +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_linkage(info r); +} +``` +* info[link info.md] + +## 概要 +リンケージを持つかを判定する。 + + +## 戻り値 +`r`がなんらかのリンケージを持つエンティティを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int global_var; // 外部リンケージ +static int internal_var; // 内部リンケージ + +int main() { + int local_var; // リンケージなし + static_assert(std::meta::has_linkage(^^global_var)); + static_assert(std::meta::has_linkage(^^internal_var)); + static_assert(!std::meta::has_linkage(^^local_var)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_module_linkage.md b/reference/meta/has_module_linkage.md new file mode 100644 index 0000000000..14fb2af677 --- /dev/null +++ b/reference/meta/has_module_linkage.md @@ -0,0 +1,57 @@ +# has_module_linkage +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_module_linkage(info r); +} +``` +* info[link info.md] + +## 概要 +モジュールリンケージを持つかを判定する。 + + +## 戻り値 +`r`がモジュールリンケージを持つエンティティを表す場合に`true`を返す。 + + +## 例 +```cpp example +// モジュール内でのモジュールリンケージの例 +export module mymodule; + +import std; + +// exportされていないモジュールスコープの宣言はモジュールリンケージを持つ +void internal_func() {} + +// exportされた宣言は外部リンケージを持つ +export void public_func() { + static_assert(std::meta::has_module_linkage(^^internal_func)); + static_assert(!std::meta::has_module_linkage(^^public_func)); + static_assert(std::meta::has_external_linkage(^^public_func)); +} +``` +* std::meta::has_module_linkage[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_parent.md b/reference/meta/has_parent.md new file mode 100644 index 0000000000..2aaba44509 --- /dev/null +++ b/reference/meta/has_parent.md @@ -0,0 +1,53 @@ +# has_parent +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_parent(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションが親スコープを持つかどうかを判定する。 + + +## 戻り値 +`r`が親スコープを持つ場合は`true`、そうでなければ`false`を返す。 + + +## 例 +```cpp example +#include + +namespace ns { + struct S {}; +} + +int main() { + static_assert(std::meta::has_parent(^^ns::S)); + static_assert(std::meta::parent_of(^^ns::S) == ^^ns); +} +``` +* std::meta::parent_of[link parent_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_static_storage_duration.md b/reference/meta/has_static_storage_duration.md new file mode 100644 index 0000000000..aca29a7afd --- /dev/null +++ b/reference/meta/has_static_storage_duration.md @@ -0,0 +1,53 @@ +# has_static_storage_duration +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_static_storage_duration(info r); +} +``` +* info[link info.md] + +## 概要 +静的記憶域期間を持つかを判定する。 + + +## 戻り値 +`r`が静的記憶域期間を持つ変数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +static int s; +int g; + +int main() { + int local; + static_assert(std::meta::has_static_storage_duration(^^s)); + static_assert(std::meta::has_static_storage_duration(^^g)); + static_assert(!std::meta::has_static_storage_duration(^^local)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_template_arguments.md b/reference/meta/has_template_arguments.md new file mode 100644 index 0000000000..c69c06158a --- /dev/null +++ b/reference/meta/has_template_arguments.md @@ -0,0 +1,50 @@ +# has_template_arguments +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_template_arguments(info r); +} +``` +* info[link info.md] + +## 概要 +テンプレート引数を持つかを判定する。 + + +## 戻り値 +`r`がテンプレートの特殊化(明示的・暗黙的を含む)を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::has_template_arguments(^^std::vector)); + static_assert(!std::meta::has_template_arguments(^^std::vector)); + static_assert(!std::meta::has_template_arguments(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_thread_storage_duration.md b/reference/meta/has_thread_storage_duration.md new file mode 100644 index 0000000000..95d8e91098 --- /dev/null +++ b/reference/meta/has_thread_storage_duration.md @@ -0,0 +1,51 @@ +# has_thread_storage_duration +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_thread_storage_duration(info r); +} +``` +* info[link info.md] + +## 概要 +スレッド記憶域期間を持つかを判定する。 + + +## 戻り値 +`r`がスレッド記憶域期間(`thread_local`)を持つ変数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +thread_local int tls_var; +int normal_var; + +int main() { + static_assert(std::meta::has_thread_storage_duration(^^tls_var)); + static_assert(!std::meta::has_thread_storage_duration(^^normal_var)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_unique_object_representations.md b/reference/meta/has_unique_object_representations.md new file mode 100644 index 0000000000..f886cec6ed --- /dev/null +++ b/reference/meta/has_unique_object_representations.md @@ -0,0 +1,55 @@ +# has_unique_object_representations +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_unique_object_representations(info type); +} +``` +* info[link info.md] + +## 概要 +型が一意なオブジェクト表現を持つかを判定する。[`std::has_unique_object_representations`](/reference/type_traits/has_unique_object_representations.md)に対応する。 + + +## 戻り値 +`type`が表す型が一意なオブジェクト表現を持つ場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::has_unique_object_representations(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::has_unique_object_representations`](/reference/type_traits/has_unique_object_representations.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/has_virtual_destructor.md b/reference/meta/has_virtual_destructor.md new file mode 100644 index 0000000000..6efe201ed3 --- /dev/null +++ b/reference/meta/has_virtual_destructor.md @@ -0,0 +1,66 @@ +# has_virtual_destructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool has_virtual_destructor(info r); +} +``` +* info[link info.md] + +## 概要 +仮想デストラクタを持つ型であるかを判定する。[`std::has_virtual_destructor`](/reference/type_traits/has_virtual_destructor.md)に対応する。 + + +## 戻り値 +`r`が表す型が仮想デストラクタを持つ場合に`true`を返す。 + + +## 例外 +`r`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Base { + virtual ~Base() = default; +}; + +struct NonVirtual { + ~NonVirtual() = default; +}; + +int main() { + static_assert(std::meta::has_virtual_destructor(^^Base)); + static_assert(!std::meta::has_virtual_destructor(^^NonVirtual)); + static_assert(!std::meta::has_virtual_destructor(^^int)); +} +``` +* std::meta::has_virtual_destructor[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::has_virtual_destructor`](/reference/type_traits/has_virtual_destructor.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/identifier_of.md b/reference/meta/identifier_of.md new file mode 100644 index 0000000000..909d5be8c8 --- /dev/null +++ b/reference/meta/identifier_of.md @@ -0,0 +1,69 @@ +# identifier_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] +* u8identifier_of[meta alias] + +```cpp +namespace std::meta { + consteval string_view identifier_of(info r); + consteval u8string_view u8identifier_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションの識別子を文字列で取得する。 + + +## 戻り値 +`r`の識別子を返す。`has_identifier(r)`が`true`であり、識別子が返す文字エンコーディングで表現可能であることが事前条件となる。 + + +## 例外 +[`has_identifier`](has_identifier.md)`(r)`が`false`の場合、または返される識別子が文字エンコーディングで表現できない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Point { + int x; + int y; +}; + +int main() { + template for (constexpr auto m : + std::meta::nonstatic_data_members_of(^^Point, + std::meta::access_context::unchecked())) { + std::println("{}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +x +y +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/info.md b/reference/meta/info.md new file mode 100644 index 0000000000..083844e4b8 --- /dev/null +++ b/reference/meta/info.md @@ -0,0 +1,73 @@ +# info +* meta[meta header] +* std::meta[meta namespace] +* type-alias[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + using info = decltype(^^::); +} +``` + +## 概要 +`info`は、リフレクションを表す型である。[リフレクション演算子`^^`](/lang/cpp26/reflection.md)によって生成される値の型であり、プログラム要素(型、名前空間、変数、関数、メンバなど)の情報を保持する。 + +型の定義において`^^::`はグローバル名前空間のリフレクションを生成する式であり、`decltype(^^::)`はその式の型を取得している。`^^`で生成されるリフレクションはすべて同じ`info`型を持つ。 + +- スカラ型であり、クラス型ではない +- `==`と`!=`をサポートするが、順序比較(`<`, `>`, `<=>`)はサポートしない +- 構造的型であり、定数テンプレートパラメータとして使用できる +- consteval-only型であり、実行時には存在できない + +2つのリフレクションは、同じエンティティを反映している場合に等値となる。 + +### ヌルリフレクション +`info`型にはヌルリフレクション (null reflection) と呼ばれる特別な値が存在する。ヌルリフレクション以外の各リフレクションは、型、名前空間、変数、関数などのプログラム構成要素を表す。ヌルリフレクションは`info{}`で生成できる。 + + +## 例 +```cpp example +#include +#include + +// 定数テンプレートパラメータとして使用 +template +using type_of_reflection = typename[:R:]; + +int main() { + // 同じエンティティを反映するリフレクションは等値 + static_assert(^^int == ^^int); + static_assert(^^int != ^^double); + + // グローバル名前空間のリフレクション + constexpr auto global_ns = ^^::; + static_assert(std::meta::is_namespace(global_ns)); + + // ヌルリフレクション + constexpr auto null = std::meta::info{}; + static_assert(null == std::meta::info{}); + static_assert(null != ^^int); + + // テンプレート引数として使用 + static_assert(std::is_same_v, int>); +} +``` +* std::meta::is_namespace[link is_namespace.md] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/invoke_result.md b/reference/meta/invoke_result.md new file mode 100644 index 0000000000..ebbdffe9b4 --- /dev/null +++ b/reference/meta/invoke_result.md @@ -0,0 +1,60 @@ +# invoke_result +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval info invoke_result(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +呼び出し可能な型の呼び出し結果型を求める。[`std::invoke_result`](/reference/type_traits/invoke_result.md)に対応する。 + + +## 戻り値 +`type`が呼び出し可能型を表し、`type_args`が引数型のリフレクションを表す場合、[`std::invoke_result`](/reference/type_traits/invoke_result.md)相当の結果型のリフレクションを返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int f(double); + +int main() { + static_assert(std::meta::invoke_result(^^decltype(f), {^^double}) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::invoke_result`](/reference/type_traits/invoke_result.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_abstract_type.md b/reference/meta/is_abstract_type.md new file mode 100644 index 0000000000..3b5165841d --- /dev/null +++ b/reference/meta/is_abstract_type.md @@ -0,0 +1,57 @@ +# is_abstract_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_abstract_type(info type); +} +``` +* info[link info.md] + +## 概要 +抽象型であるかを判定する。 + + +## 戻り値 +`type`が純粋仮想関数を持つクラス型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Abstract { virtual void f() = 0; }; + +int main() { + static_assert(std::meta::is_abstract_type(^^Abstract)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_abstract`](/reference/type_traits/is_abstract.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_accessible.md b/reference/meta/is_accessible.md new file mode 100644 index 0000000000..142de0671a --- /dev/null +++ b/reference/meta/is_accessible.md @@ -0,0 +1,66 @@ +# is_accessible +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_accessible(info r, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +指定したアクセスコンテキストでアクセス可能かを判定する。 + + +## 戻り値 +`r`がアクセスコンテキスト`ctx`でアクセス可能である場合に`true`を返す。 + + +## 例外 +`r`が不完全なクラスのメンバ、または不完全なクラスの基底クラス関係を表す場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +class C { + int secret; +public: + int visible; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^C, std::meta::access_context::unchecked()); + constexpr auto ctx = std::meta::access_context::unprivileged(); + static_assert(!std::meta::is_accessible(members[0], ctx)); // secret: private + static_assert(std::meta::is_accessible(members[1], ctx)); // visible: public +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* unprivileged[link access_context/unprivileged.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_aggregate_type.md b/reference/meta/is_aggregate_type.md new file mode 100644 index 0000000000..dbf70579b6 --- /dev/null +++ b/reference/meta/is_aggregate_type.md @@ -0,0 +1,57 @@ +# is_aggregate_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_aggregate_type(info type); +} +``` +* info[link info.md] + +## 概要 +集成体型であるかを判定する。 + + +## 戻り値 +`type`が集成体型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Agg { int x; int y; }; + +int main() { + static_assert(std::meta::is_aggregate_type(^^Agg)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_aggregate`](/reference/type_traits/is_aggregate.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_alias_template.md b/reference/meta/is_alias_template.md new file mode 100644 index 0000000000..f1553a055d --- /dev/null +++ b/reference/meta/is_alias_template.md @@ -0,0 +1,50 @@ +# is_alias_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_alias_template(info r); +} +``` +* info[link info.md] + +## 概要 +エイリアステンプレートであるかを判定する。 + + +## 戻り値 +`r`がエイリアステンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +template +using ptr = T*; + +int main() { + static_assert(std::meta::is_alias_template(^^ptr)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_annotation.md b/reference/meta/is_annotation.md new file mode 100644 index 0000000000..919b109de7 --- /dev/null +++ b/reference/meta/is_annotation.md @@ -0,0 +1,59 @@ +# is_annotation +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_annotation(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションがアノテーションであるかを判定する。 + + +## 戻り値 +`r`がアノテーションを表す場合に`true`を返す。そうでなければ`false`を返す。 + + +## 例 +```cpp example +#include + +struct Tag {}; + +struct [[=Tag{}]] S {}; + +int main() { + constexpr auto annots = std::meta::annotations_of(^^S); + static_assert(annots.size() == 1); + static_assert(std::meta::is_annotation(annots[0])); +} +``` +* std::meta::annotations_of[link annotations_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`annotations_of`](annotations_of.md) +- [`annotations_of_with_type`](annotations_of_with_type.md) + + +## 参照 +- [P3394R4 Annotations for Reflection](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3394r4.html) diff --git a/reference/meta/is_arithmetic_type.md b/reference/meta/is_arithmetic_type.md new file mode 100644 index 0000000000..d4f3e4b673 --- /dev/null +++ b/reference/meta/is_arithmetic_type.md @@ -0,0 +1,55 @@ +# is_arithmetic_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_arithmetic_type(info type); +} +``` +* info[link info.md] + +## 概要 +算術型であるかを判定する。 + + +## 戻り値 +`type`が算術型(整数型または浮動小数点数型)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_arithmetic_type(^^int)); + static_assert(!std::meta::is_arithmetic_type(^^int*)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_arithmetic`](/reference/type_traits/is_arithmetic.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_array_type.md b/reference/meta/is_array_type.md new file mode 100644 index 0000000000..d2e0e7a3bc --- /dev/null +++ b/reference/meta/is_array_type.md @@ -0,0 +1,55 @@ +# is_array_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_array_type(info type); +} +``` +* info[link info.md] + +## 概要 +配列型であるかを判定する。 + + +## 戻り値 +`type`が配列型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_array_type(^^int[3])); + static_assert(!std::meta::is_array_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_array`](/reference/type_traits/is_array.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_assignable_type.md b/reference/meta/is_assignable_type.md new file mode 100644 index 0000000000..06d734cd56 --- /dev/null +++ b/reference/meta/is_assignable_type.md @@ -0,0 +1,67 @@ +# is_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_assignable_type(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +式`declval() = declval()`が有効かどうかで代入可能かを判定する。[`std::is_assignable`](/reference/type_traits/is_assignable.md)に対応する。 + + +## 戻り値 +`type_dst`と`type_src`が表す型について、代入が可能な場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct A {}; +struct B { + B& operator=(const A&) { return *this; } +}; + +int main() { + // int&にintを代入可能 + static_assert(std::meta::is_assignable_type(^^int&, ^^int)); + // intにintは代入不可(左辺が左辺値参照でない) + static_assert(!std::meta::is_assignable_type(^^int, ^^int)); + // const int&にintは代入不可 + static_assert(!std::meta::is_assignable_type(^^const int&, ^^int)); + + // BにはAからの代入演算子が定義されている + static_assert(std::meta::is_assignable_type(^^B&, ^^const A&)); + // AにはBからの代入演算子が定義されていない + static_assert(!std::meta::is_assignable_type(^^A&, ^^const B&)); +} +``` +* std::meta::is_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_assignment.md b/reference/meta/is_assignment.md new file mode 100644 index 0000000000..71ee5fab5e --- /dev/null +++ b/reference/meta/is_assignment.md @@ -0,0 +1,67 @@ +# is_assignment +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_assignment(info r); +} +``` +* info[link info.md] + +## 概要 +代入演算子(コピー代入演算子およびムーブ代入演算子)であるかを判定する。 + + +## 戻り値 +`r`が代入演算子を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + S& operator=(const S&) = default; // コピー代入演算子 + S& operator=(S&&) = default; // ムーブ代入演算子 + S& operator=(int) { return *this; } // 代入演算子ではない(通常のoperator=) +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_function(m)) { + std::println("{}: is_assignment={}", + std::meta::display_string_of(m), + std::meta::is_assignment(m)); + } + } +} +``` +* std::meta::members_of[link members_of.md] +* std::meta::is_function[link is_function.md] +* std::meta::display_string_of[link display_string_of.md] + +#### 出力例 +``` +S::operator=(const S&): is_assignment=true +S::operator=(S&&): is_assignment=true +S::operator=(int): is_assignment=false +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_base.md b/reference/meta/is_base.md new file mode 100644 index 0000000000..163dd8bdf1 --- /dev/null +++ b/reference/meta/is_base.md @@ -0,0 +1,56 @@ +# is_base +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_base(info r); +} +``` +* info[link info.md] + +## 概要 +基底クラス関係であるかを判定する。 + + +## 戻り値 +`r`が直接基底クラス関係を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Base {}; +struct Derived : Base {}; + +int main() { + constexpr auto bases = std::meta::bases_of( + ^^Derived, std::meta::access_context::unchecked()); + static_assert(bases.size() == 1); + static_assert(std::meta::is_base(bases[0])); +} +``` +* std::meta::bases_of[link bases_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_base_of_type.md b/reference/meta/is_base_of_type.md new file mode 100644 index 0000000000..60e8ad877c --- /dev/null +++ b/reference/meta/is_base_of_type.md @@ -0,0 +1,59 @@ +# is_base_of_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_base_of_type(info type_base, info type_derived); +} +``` +* info[link info.md] + +## 概要 +型が別の型の基底クラスであるかを判定する。[`std::is_base_of`](/reference/type_traits/is_base_of.md)に対応する。 + + +## 戻り値 +`type_base`が`type_derived`の基底クラスである場合に`true`を返す。 + + +## 例外 +`type_base`または`type_derived`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Base {}; +struct Derived : Base {}; + +int main() { + static_assert(std::meta::is_base_of_type(^^Base, ^^Derived)); + static_assert(!std::meta::is_base_of_type(^^Derived, ^^Base)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_base_of`](/reference/type_traits/is_base_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_bit_field.md b/reference/meta/is_bit_field.md new file mode 100644 index 0000000000..06e89dcea2 --- /dev/null +++ b/reference/meta/is_bit_field.md @@ -0,0 +1,60 @@ +# is_bit_field +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_bit_field(info r); +} +``` +* info[link info.md] + +## 概要 +ビットフィールドであるかを判定する。 + + +## 戻り値 +`r`がビットフィールドを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Flags { + unsigned a : 1; + unsigned b : 3; + unsigned c; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^Flags, std::meta::access_context::unchecked()); + static_assert(std::meta::is_bit_field(members[0])); // a + static_assert(std::meta::is_bit_field(members[1])); // b + static_assert(!std::meta::is_bit_field(members[2])); // c +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_bounded_array_type.md b/reference/meta/is_bounded_array_type.md new file mode 100644 index 0000000000..2a96f5cdad --- /dev/null +++ b/reference/meta/is_bounded_array_type.md @@ -0,0 +1,55 @@ +# is_bounded_array_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_bounded_array_type(info type); +} +``` +* info[link info.md] + +## 概要 +境界付き配列型であるかを判定する。 + + +## 戻り値 +`type`が境界付き配列型(`T[N]`)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_bounded_array_type(^^int[3])); + static_assert(!std::meta::is_bounded_array_type(^^int[])); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_bounded_array`](/reference/type_traits/is_bounded_array.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_class_member.md b/reference/meta/is_class_member.md new file mode 100644 index 0000000000..cfd0860aa8 --- /dev/null +++ b/reference/meta/is_class_member.md @@ -0,0 +1,53 @@ +# is_class_member +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_class_member(info r); +} +``` +* info[link info.md] + +## 概要 +クラスメンバであるかを判定する。 + + +## 戻り値 +`r`がクラスのメンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int x; + void f() {} +}; + +int main() { + static_assert(std::meta::is_class_member(^^S::x)); + static_assert(std::meta::is_class_member(^^S::f)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_class_template.md b/reference/meta/is_class_template.md new file mode 100644 index 0000000000..026dbbe55e --- /dev/null +++ b/reference/meta/is_class_template.md @@ -0,0 +1,48 @@ +# is_class_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_class_template(info r); +} +``` +* info[link info.md] + +## 概要 +クラステンプレートであるかを判定する。 + + +## 戻り値 +`r`がクラステンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::is_class_template(^^std::vector)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_class_type.md b/reference/meta/is_class_type.md new file mode 100644 index 0000000000..d1d516febc --- /dev/null +++ b/reference/meta/is_class_type.md @@ -0,0 +1,58 @@ +# is_class_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_class_type(info type); +} +``` +* info[link info.md] + +## 概要 +クラス型であるかを判定する。 + + +## 戻り値 +`type`がクラス型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct S {{ int x; }}; + +int main() { + static_assert(std::meta::is_class_type(^^S)); + static_assert(!std::meta::is_class_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_class`](/reference/type_traits/is_class.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_complete_type.md b/reference/meta/is_complete_type.md new file mode 100644 index 0000000000..67dbed573e --- /dev/null +++ b/reference/meta/is_complete_type.md @@ -0,0 +1,50 @@ +# is_complete_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_complete_type(info r); +} +``` +* info[link info.md] + +## 概要 +型が完全型であるかを判定する。 + + +## 戻り値 +`r`が完全型を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { int x; }; +struct Incomplete; + +int main() { + static_assert(std::meta::is_complete_type(^^S)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_compound_type.md b/reference/meta/is_compound_type.md new file mode 100644 index 0000000000..0f30584432 --- /dev/null +++ b/reference/meta/is_compound_type.md @@ -0,0 +1,55 @@ +# is_compound_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_compound_type(info type); +} +``` +* info[link info.md] + +## 概要 +複合型であるかを判定する。 + + +## 戻り値 +`type`が複合型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_compound_type(^^int*)); + static_assert(!std::meta::is_compound_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_compound`](/reference/type_traits/is_compound.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_concept.md b/reference/meta/is_concept.md new file mode 100644 index 0000000000..8867c4fbf9 --- /dev/null +++ b/reference/meta/is_concept.md @@ -0,0 +1,50 @@ +# is_concept +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_concept(info r); +} +``` +* info[link info.md] + +## 概要 +コンセプトであるかを判定する。 + + +## 戻り値 +`r`がコンセプトを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::is_concept(^^std::integral)); + static_assert(!std::meta::is_concept(^^int)); +} +``` +* std::integral[link /reference/concepts/integral.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_const.md b/reference/meta/is_const.md new file mode 100644 index 0000000000..e1b412f599 --- /dev/null +++ b/reference/meta/is_const.md @@ -0,0 +1,53 @@ +# is_const +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_const(info r); +} +``` +* info[link info.md] + +## 概要 +`const`修飾されているかを判定する。 + + +## 戻り値 +`r`が`const`修飾されたメンバ関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + void f() {} + void g() const {} +}; + +int main() { + static_assert(!std::meta::is_const(^^S::f)); + static_assert(std::meta::is_const(^^S::g)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_const_type.md b/reference/meta/is_const_type.md new file mode 100644 index 0000000000..04ce149e4e --- /dev/null +++ b/reference/meta/is_const_type.md @@ -0,0 +1,55 @@ +# is_const_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_const_type(info type); +} +``` +* info[link info.md] + +## 概要 +`const`修飾された型であるかを判定する。 + + +## 戻り値 +`type`が最上位で`const`修飾された型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_const_type(^^const int)); + static_assert(!std::meta::is_const_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_const`](/reference/type_traits/is_const.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_consteval_only_type.md b/reference/meta/is_consteval_only_type.md new file mode 100644 index 0000000000..3f4d13587a --- /dev/null +++ b/reference/meta/is_consteval_only_type.md @@ -0,0 +1,55 @@ +# is_consteval_only_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_consteval_only_type(info type); +} +``` +* info[link info.md] + +## 概要 +consteval-only型であるかを判定する。[`std::is_consteval_only`](/reference/type_traits/is_consteval_only.md)に対応する。 + + +## 戻り値 +`type`が表す型がconsteval-only型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_consteval_only_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_consteval_only`](/reference/type_traits/is_consteval_only.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_constructible_type.md b/reference/meta/is_constructible_type.md new file mode 100644 index 0000000000..918bcc6088 --- /dev/null +++ b/reference/meta/is_constructible_type.md @@ -0,0 +1,60 @@ +# is_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_constructible_type(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +指定した引数型で構築可能かを判定する。[`std::is_constructible`](/reference/type_traits/is_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が`type_args`で指定された引数型で構築可能な場合に`true`を返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + // stringはconst char*から構築可能 + static_assert(std::meta::is_constructible_type(^^std::string, {^^const char*})); + // intは引数なしで構築可能 + static_assert(std::meta::is_constructible_type(^^int, {})); + // intはstring_viewから構築不可能 + static_assert(!std::meta::is_constructible_type(^^int, {^^std::string_view})); +} +``` +* std::meta::is_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_constructor.md b/reference/meta/is_constructor.md new file mode 100644 index 0000000000..e2d171f99a --- /dev/null +++ b/reference/meta/is_constructor.md @@ -0,0 +1,71 @@ +# is_constructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_constructor(info r); +} +``` +* info[link info.md] + +## 概要 +コンストラクタであるかを判定する。 + + +## 戻り値 +`r`がコンストラクタを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + S() = default; // デフォルトコンストラクタ + S(int) {} // 変換コンストラクタ + S(const S&) = default; // コピーコンストラクタ + void f() {} // 通常のメンバ関数 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_function(m)) { + std::println("{}: is_constructor={}", + std::meta::display_string_of(m), + std::meta::is_constructor(m)); + } + } +} +``` +* std::meta::members_of[link members_of.md] +* std::meta::is_function[link is_function.md] +* std::meta::display_string_of[link display_string_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +S::S(): is_constructor=true +S::S(int): is_constructor=true +S::S(const S&): is_constructor=true +S::f(): is_constructor=false +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_constructor_template.md b/reference/meta/is_constructor_template.md new file mode 100644 index 0000000000..8050330cf7 --- /dev/null +++ b/reference/meta/is_constructor_template.md @@ -0,0 +1,66 @@ +# is_constructor_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_constructor_template(info r); +} +``` +* info[link info.md] + +## 概要 +コンストラクタテンプレートであるかを判定する。コンストラクタテンプレートとは、テンプレート化されたコンストラクタ(`template S(T)`のような形式)のことである。 + + +## 戻り値 +`r`がコンストラクタテンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; // コンストラクタ(テンプレートではない) + template + S(T) {} // コンストラクタテンプレート +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_constructor_template(m)) { + // template S(T) のみがここに到達する + static_assert(std::meta::is_template(m)); + static_assert(!std::meta::is_default_constructor(m)); + } + } +} +``` +* std::meta::is_constructor_template[color ff0000] +* std::meta::is_template[link is_template.md] +* std::meta::is_default_constructor[link is_default_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_conversion_function.md b/reference/meta/is_conversion_function.md new file mode 100644 index 0000000000..799c576bc7 --- /dev/null +++ b/reference/meta/is_conversion_function.md @@ -0,0 +1,69 @@ +# is_conversion_function +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_conversion_function(info r); +} +``` +* info[link info.md] + +## 概要 +変換関数であるかを判定する。 + +変換関数とは、クラスのオブジェクトを別の型に暗黙的または明示的に変換するための`operator T()`形式のメンバ関数である。 + + +## 戻り値 +`r`が変換関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + int value; + operator int() const { return value; } // 変換関数 + explicit operator bool() const { return value != 0; } // 変換関数 + void f() {} // 通常のメンバ関数 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_conversion_function(m)) { + std::println("{}", std::meta::display_string_of(m)); + } + } +} +``` +* std::meta::members_of[link members_of.md] +* std::meta::is_conversion_function[color ff0000] +* std::meta::display_string_of[link display_string_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +S::operator int() +S::operator bool() +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_conversion_function_template.md b/reference/meta/is_conversion_function_template.md new file mode 100644 index 0000000000..ab74a9e3e9 --- /dev/null +++ b/reference/meta/is_conversion_function_template.md @@ -0,0 +1,66 @@ +# is_conversion_function_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_conversion_function_template(info r); +} +``` +* info[link info.md] + +## 概要 +変換関数テンプレートであるかを判定する。変換関数テンプレートとは、`template operator T()`のようなテンプレート化された変換関数のことである。 + + +## 戻り値 +`r`が変換関数テンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + operator int() const { return 0; } // 変換関数 + template + operator T() const { return T{}; } // 変換関数テンプレート +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_conversion_function_template(m)) { + // template operator T() のみがここに到達する + static_assert(std::meta::is_template(m)); + static_assert(!std::meta::is_conversion_function(m)); + } + } +} +``` +* std::meta::is_conversion_function_template[color ff0000] +* std::meta::is_template[link is_template.md] +* std::meta::is_conversion_function[link is_conversion_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_convertible_type.md b/reference/meta/is_convertible_type.md new file mode 100644 index 0000000000..199e110bbf --- /dev/null +++ b/reference/meta/is_convertible_type.md @@ -0,0 +1,56 @@ +# is_convertible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_convertible_type(info type_src, info type_dst); +} +``` +* info[link info.md] + +## 概要 +型が別の型に暗黙変換可能かを判定する。[`std::is_convertible`](/reference/type_traits/is_convertible.md)に対応する。 + + +## 戻り値 +`type_src`が`type_dst`に暗黙変換可能な場合に`true`を返す。 + + +## 例外 +`type_src`または`type_dst`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_convertible_type(^^int, ^^double)); + static_assert(!std::meta::is_convertible_type(^^int*, ^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_convertible`](/reference/type_traits/is_convertible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_copy_assignable_type.md b/reference/meta/is_copy_assignable_type.md new file mode 100644 index 0000000000..87ec3f352a --- /dev/null +++ b/reference/meta/is_copy_assignable_type.md @@ -0,0 +1,55 @@ +# is_copy_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_copy_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +コピー代入可能型であるかを判定する。[`std::is_copy_assignable`](/reference/type_traits/is_copy_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型がコピー代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_copy_assignable_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_copy_assignable`](/reference/type_traits/is_copy_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_copy_assignment.md b/reference/meta/is_copy_assignment.md new file mode 100644 index 0000000000..e049cccba8 --- /dev/null +++ b/reference/meta/is_copy_assignment.md @@ -0,0 +1,64 @@ +# is_copy_assignment +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_copy_assignment(info r); +} +``` +* info[link info.md] + +## 概要 +コピー代入演算子であるかを判定する。 + + +## 戻り値 +`r`がコピー代入演算子を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S& operator=(const S&) = default; // コピー代入演算子 + S& operator=(S&&) = default; // ムーブ代入演算子 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_copy_assignment(m)) { + static_assert(!std::meta::is_move_assignment(m)); + } + if constexpr (std::meta::is_move_assignment(m)) { + static_assert(!std::meta::is_copy_assignment(m)); + } + } +} +``` +* std::meta::is_move_assignment[link is_move_assignment.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_copy_constructible_type.md b/reference/meta/is_copy_constructible_type.md new file mode 100644 index 0000000000..8801eb2e29 --- /dev/null +++ b/reference/meta/is_copy_constructible_type.md @@ -0,0 +1,55 @@ +# is_copy_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_copy_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +コピー構築可能型であるかを判定する。[`std::is_copy_constructible`](/reference/type_traits/is_copy_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がコピー構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_copy_constructible_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_copy_constructible`](/reference/type_traits/is_copy_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_copy_constructor.md b/reference/meta/is_copy_constructor.md new file mode 100644 index 0000000000..3466be2f57 --- /dev/null +++ b/reference/meta/is_copy_constructor.md @@ -0,0 +1,68 @@ +# is_copy_constructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_copy_constructor(info r); +} +``` +* info[link info.md] + +## 概要 +コピーコンストラクタであるかを判定する。 + + +## 戻り値 +`r`がコピーコンストラクタを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; + S(const S&) = default; // コピーコンストラクタ + S(S&&) = default; // ムーブコンストラクタ + S(int) {} // コピーでもムーブでもないコンストラクタ +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_copy_constructor(m)) { + // S(const S&)のみがここに到達する + static_assert(std::meta::is_constructor(m)); + static_assert(!std::meta::is_move_constructor(m)); + static_assert(std::meta::is_special_member_function(m)); + } + } +} +``` +* std::meta::is_constructor[link is_constructor.md] +* std::meta::is_move_constructor[link is_move_constructor.md] +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_data_member_spec.md b/reference/meta/is_data_member_spec.md new file mode 100644 index 0000000000..ba26a80ea1 --- /dev/null +++ b/reference/meta/is_data_member_spec.md @@ -0,0 +1,58 @@ +# is_data_member_spec +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_data_member_spec(info r); +} +``` +* info[link info.md] + +## 概要 +[`data_member_spec()`](data_member_spec.md)によって作成されたデータメンバの仕様であるかを判定する。 + + +## 戻り値 +`r`が[`data_member_spec()`](data_member_spec.md)によって作成されたデータメンバの仕様を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S; + +consteval { + std::meta::define_aggregate(^^S, { + std::meta::data_member_spec(^^int, {.name = "x"}), + std::meta::data_member_spec(^^double, {.name = "y"}) + }); +} + +int main() { + S s{1, 2.0}; + static_assert(std::meta::is_data_member_spec( + std::meta::data_member_spec(^^int, {.name = "z"}))); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_default_constructible_type.md b/reference/meta/is_default_constructible_type.md new file mode 100644 index 0000000000..ccf2d0839d --- /dev/null +++ b/reference/meta/is_default_constructible_type.md @@ -0,0 +1,55 @@ +# is_default_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_default_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +デフォルト構築可能型であるかを判定する。[`std::is_default_constructible`](/reference/type_traits/is_default_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がデフォルト構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_default_constructible_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_default_constructible`](/reference/type_traits/is_default_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_default_constructor.md b/reference/meta/is_default_constructor.md new file mode 100644 index 0000000000..b05e053c33 --- /dev/null +++ b/reference/meta/is_default_constructor.md @@ -0,0 +1,69 @@ +# is_default_constructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_default_constructor(info r); +} +``` +* info[link info.md] + +## 概要 +デフォルトコンストラクタであるかを判定する。 + + +## 戻り値 +`r`がデフォルトコンストラクタを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; // デフォルトコンストラクタ + S(int) {} // デフォルトコンストラクタではない + S(const S&) = default; // コピーコンストラクタ +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_constructor(m)) { + if constexpr (std::meta::is_default_constructor(m)) { + // S()のみがここに到達する + static_assert(std::meta::is_defaulted(m)); + static_assert(std::meta::is_special_member_function(m)); + } + } + } +} +``` +* std::meta::is_default_constructor[color ff0000] +* std::meta::is_constructor[link is_constructor.md] +* std::meta::is_defaulted[link is_defaulted.md] +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_defaulted.md b/reference/meta/is_defaulted.md new file mode 100644 index 0000000000..86289295cc --- /dev/null +++ b/reference/meta/is_defaulted.md @@ -0,0 +1,61 @@ +# is_defaulted +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_defaulted(info r); +} +``` +* info[link info.md] + +## 概要 +`= default`されているかを判定する。 + + +## 戻り値 +`r`が`= default`された関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; + S(int) {} +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_default_constructor(m)) { + static_assert(std::meta::is_defaulted(m)); + } + } +} +``` +* std::meta::is_default_constructor[link is_default_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_deleted.md b/reference/meta/is_deleted.md new file mode 100644 index 0000000000..f84102775d --- /dev/null +++ b/reference/meta/is_deleted.md @@ -0,0 +1,61 @@ +# is_deleted +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_deleted(info r); +} +``` +* info[link info.md] + +## 概要 +`= delete`されているかを判定する。 + + +## 戻り値 +`r`が`= delete`された関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct NonCopyable { + NonCopyable() = default; + NonCopyable(const NonCopyable&) = delete; +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^NonCopyable, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_copy_constructor(m)) { + static_assert(std::meta::is_deleted(m)); + } + } +} +``` +* std::meta::is_copy_constructor[link is_copy_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_destructible_type.md b/reference/meta/is_destructible_type.md new file mode 100644 index 0000000000..ab124d9b10 --- /dev/null +++ b/reference/meta/is_destructible_type.md @@ -0,0 +1,55 @@ +# is_destructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_destructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +破棄可能型であるかを判定する。[`std::is_destructible`](/reference/type_traits/is_destructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が破棄可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_destructible_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_destructible`](/reference/type_traits/is_destructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_destructor.md b/reference/meta/is_destructor.md new file mode 100644 index 0000000000..6869a27d7b --- /dev/null +++ b/reference/meta/is_destructor.md @@ -0,0 +1,65 @@ +# is_destructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_destructor(info r); +} +``` +* info[link info.md] + +## 概要 +デストラクタであるかを判定する。 + + +## 戻り値 +`r`がデストラクタを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; + ~S() = default; // デストラクタ + void f() {} // 通常のメンバ関数 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_destructor(m)) { + // ~S()のみがここに到達する + static_assert(std::meta::is_special_member_function(m)); + static_assert(!std::meta::is_constructor(m)); + } + } +} +``` +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::is_constructor[link is_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_empty_type.md b/reference/meta/is_empty_type.md new file mode 100644 index 0000000000..268eace7a0 --- /dev/null +++ b/reference/meta/is_empty_type.md @@ -0,0 +1,57 @@ +# is_empty_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_empty_type(info type); +} +``` +* info[link info.md] + +## 概要 +空の型であるかを判定する。 + + +## 戻り値 +`type`が空のクラス型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Empty {}; + +int main() { + static_assert(std::meta::is_empty_type(^^Empty)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_empty`](/reference/type_traits/is_empty.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_enum_type.md b/reference/meta/is_enum_type.md new file mode 100644 index 0000000000..0a532c072d --- /dev/null +++ b/reference/meta/is_enum_type.md @@ -0,0 +1,58 @@ +# is_enum_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_enum_type(info type); +} +``` +* info[link info.md] + +## 概要 +列挙型であるかを判定する。 + + +## 戻り値 +`type`が列挙型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +enum class Color { red, green, blue }; + +int main() { + static_assert(std::meta::is_enum_type(^^Color)); + static_assert(!std::meta::is_enum_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_enum`](/reference/type_traits/is_enum.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_enumerable_type.md b/reference/meta/is_enumerable_type.md new file mode 100644 index 0000000000..04cdfad3f4 --- /dev/null +++ b/reference/meta/is_enumerable_type.md @@ -0,0 +1,49 @@ +# is_enumerable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_enumerable_type(info r); +} +``` +* info[link info.md] + +## 概要 +型が列挙可能型であるかを判定する。列挙可能型とは、[`enumerators_of()`](enumerators_of.md)で列挙子を取得できる列挙型である。 + + +## 戻り値 +`r`が列挙可能な列挙型を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +enum Color { red, green, blue }; + +int main() { + static_assert(std::meta::is_enumerable_type(^^Color)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_enumerator.md b/reference/meta/is_enumerator.md new file mode 100644 index 0000000000..4aff83671a --- /dev/null +++ b/reference/meta/is_enumerator.md @@ -0,0 +1,50 @@ +# is_enumerator +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_enumerator(info r); +} +``` +* info[link info.md] + +## 概要 +列挙子であるかを判定する。 + + +## 戻り値 +`r`が列挙子を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +enum Color { red, green, blue }; + +int main() { + static_assert(std::meta::is_enumerator(^^Color::red)); + static_assert(!std::meta::is_enumerator(^^Color)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_explicit.md b/reference/meta/is_explicit.md new file mode 100644 index 0000000000..d9edb1e69b --- /dev/null +++ b/reference/meta/is_explicit.md @@ -0,0 +1,65 @@ +# is_explicit +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_explicit(info r); +} +``` +* info[link info.md] + +## 概要 +`explicit`であるかを判定する。 + + +## 戻り値 +`r`が`explicit`指定されたコンストラクタまたは変換関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + explicit S(int) {} + S(double) {} +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_constructor(m) && + !std::meta::is_special_member_function(m)) { + if constexpr (std::meta::is_explicit(m)) { + // S(int) はexplicit + } + } + } +} +``` +* std::meta::is_constructor[link is_constructor.md] +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_explicit_object_parameter.md b/reference/meta/is_explicit_object_parameter.md new file mode 100644 index 0000000000..b06e1f8a84 --- /dev/null +++ b/reference/meta/is_explicit_object_parameter.md @@ -0,0 +1,57 @@ +# is_explicit_object_parameter +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_explicit_object_parameter(info r); +} +``` +* info[link info.md] + +## 概要 +関数パラメータが明示的オブジェクトパラメータ(`this`引数)であるかを判定する。 + + +## 戻り値 +`r`が関数パラメータを表し、かつ明示的オブジェクトパラメータ(`this`引数)である場合に`true`を返す。そうでなければ`false`を返す。 + + +## 例 +```cpp example +#include + +struct S { + void f(this S& self) {} // 明示的オブジェクトパラメータ + void g(int x) {} // 通常のパラメータ +}; + +int main() { + constexpr auto f_params = std::meta::parameters_of(^^S::f); + static_assert(std::meta::is_explicit_object_parameter(f_params[0])); + + constexpr auto g_params = std::meta::parameters_of(^^S::g); + static_assert(!std::meta::is_explicit_object_parameter(g_params[0])); +} +``` +* std::meta::parameters_of[link parameters_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/is_final.md b/reference/meta/is_final.md new file mode 100644 index 0000000000..7f180bd6ad --- /dev/null +++ b/reference/meta/is_final.md @@ -0,0 +1,57 @@ +# is_final +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_final(info r); +} +``` +* info[link info.md] + +## 概要 +`final`指定されているかを判定する。 + + +## 戻り値 +`r`が`final`指定されたメンバ関数またはクラスを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Base { + virtual void f() {} +}; + +struct Derived final : Base { + void f() final {} +}; + +int main() { + static_assert(std::meta::is_final(^^Derived)); + static_assert(std::meta::is_final(^^Derived::f)); + static_assert(!std::meta::is_final(^^Base)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_final_type.md b/reference/meta/is_final_type.md new file mode 100644 index 0000000000..de75f1436d --- /dev/null +++ b/reference/meta/is_final_type.md @@ -0,0 +1,57 @@ +# is_final_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_final_type(info type); +} +``` +* info[link info.md] + +## 概要 +`final`指定された型であるかを判定する。 + + +## 戻り値 +`type`が`final`指定されたクラス型を表す場合に`true`を返す。 + + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + +## 例 +```cpp example +#include + +struct Final final {}; + +int main() { + static_assert(std::meta::is_final_type(^^Final)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_final`](/reference/type_traits/is_final.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_floating_point_type.md b/reference/meta/is_floating_point_type.md new file mode 100644 index 0000000000..95ff83adfc --- /dev/null +++ b/reference/meta/is_floating_point_type.md @@ -0,0 +1,56 @@ +# is_floating_point_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_floating_point_type(info type); +} +``` +* info[link info.md] + +## 概要 +浮動小数点数型であるかを判定する。 + + +## 戻り値 +`type`が浮動小数点数型を表す場合に`true`を返す。 + + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_floating_point_type(^^double)); + static_assert(!std::meta::is_floating_point_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_floating_point`](/reference/type_traits/is_floating_point.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_function.md b/reference/meta/is_function.md new file mode 100644 index 0000000000..86f406907c --- /dev/null +++ b/reference/meta/is_function.md @@ -0,0 +1,50 @@ +# is_function +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_function(info r); +} +``` +* info[link info.md] + +## 概要 +関数であるかを判定する。 + + +## 戻り値 +`r`が関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +void f() {} + +int main() { + static_assert(std::meta::is_function(^^f)); + static_assert(!std::meta::is_function(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_function_parameter.md b/reference/meta/is_function_parameter.md new file mode 100644 index 0000000000..d1287da401 --- /dev/null +++ b/reference/meta/is_function_parameter.md @@ -0,0 +1,53 @@ +# is_function_parameter +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_function_parameter(info r); +} +``` +* info[link info.md] + +## 概要 +関数パラメータであるかを判定する。 + + +## 戻り値 +`r`が関数パラメータを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +void func(int x, double y); + +int main() { + constexpr auto params = std::meta::parameters_of(^^func); + static_assert(std::meta::is_function_parameter(params[0])); + static_assert(std::meta::is_function_parameter(params[1])); +} +``` +* std::meta::parameters_of[link parameters_of.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/is_function_template.md b/reference/meta/is_function_template.md new file mode 100644 index 0000000000..597b98d947 --- /dev/null +++ b/reference/meta/is_function_template.md @@ -0,0 +1,49 @@ +# is_function_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_function_template(info r); +} +``` +* info[link info.md] + +## 概要 +関数テンプレートであるかを判定する。 + + +## 戻り値 +`r`が関数テンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::is_function_template(^^std::sort)); +} +``` +* std::sort[link /reference/algorithm/sort.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_function_type.md b/reference/meta/is_function_type.md new file mode 100644 index 0000000000..dd0380d7fb --- /dev/null +++ b/reference/meta/is_function_type.md @@ -0,0 +1,56 @@ +# is_function_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_function_type(info type); +} +``` +* info[link info.md] + +## 概要 +関数型であるかを判定する。 + + +## 戻り値 +`type`が関数型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_function_type(^^int(double))); + static_assert(!std::meta::is_function_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_function`](/reference/type_traits/is_function.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_fundamental_type.md b/reference/meta/is_fundamental_type.md new file mode 100644 index 0000000000..2c67ad8663 --- /dev/null +++ b/reference/meta/is_fundamental_type.md @@ -0,0 +1,55 @@ +# is_fundamental_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_fundamental_type(info type); +} +``` +* info[link info.md] + +## 概要 +基本型であるかを判定する。 + + +## 戻り値 +`type`が基本型(算術型、`void`、`nullptr_t`)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_fundamental_type(^^int)); + static_assert(!std::meta::is_fundamental_type(^^std::string)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_fundamental`](/reference/type_traits/is_fundamental.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_implicit_lifetime_type.md b/reference/meta/is_implicit_lifetime_type.md new file mode 100644 index 0000000000..708a66e6c3 --- /dev/null +++ b/reference/meta/is_implicit_lifetime_type.md @@ -0,0 +1,55 @@ +# is_implicit_lifetime_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_implicit_lifetime_type(info type); +} +``` +* info[link info.md] + +## 概要 +暗黙の生存期間型であるかを判定する。[`std::is_implicit_lifetime`](/reference/type_traits/is_implicit_lifetime.md)に対応する。 + + +## 戻り値 +`type`が表す型が暗黙の生存期間型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_implicit_lifetime_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_implicit_lifetime`](/reference/type_traits/is_implicit_lifetime.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_integral_type.md b/reference/meta/is_integral_type.md new file mode 100644 index 0000000000..1633d95c02 --- /dev/null +++ b/reference/meta/is_integral_type.md @@ -0,0 +1,55 @@ +# is_integral_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_integral_type(info type); +} +``` +* info[link info.md] + +## 概要 +整数型であるかを判定する。 + + +## 戻り値 +`type`が整数型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_integral_type(^^int)); + static_assert(!std::meta::is_integral_type(^^double)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_integral`](/reference/type_traits/is_integral.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_invocable_r_type.md b/reference/meta/is_invocable_r_type.md new file mode 100644 index 0000000000..f00a4be5e9 --- /dev/null +++ b/reference/meta/is_invocable_r_type.md @@ -0,0 +1,59 @@ +# is_invocable_r_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_invocable_r_type(info type_result, info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +呼び出し可能で戻り値が指定型に変換可能かを判定する。[`std::is_invocable_r`](/reference/type_traits/is_invocable_r.md)に対応する。 + + +## 戻り値 +`type`が`type_args`で呼び出し可能で、戻り値が`type_result`に変換可能な場合に`true`を返す。 + + +## 例外 +`type_result`、`type`、または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int f(double) { return 0; } + +int main() { + static_assert(std::meta::is_invocable_r_type(^^int, ^^decltype(f), {^^double})); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_invocable_r`](/reference/type_traits/is_invocable_r.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_invocable_type.md b/reference/meta/is_invocable_type.md new file mode 100644 index 0000000000..696ab61081 --- /dev/null +++ b/reference/meta/is_invocable_type.md @@ -0,0 +1,60 @@ +# is_invocable_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_invocable_type(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +呼び出し可能な型であるかを判定する。[`std::is_invocable`](/reference/type_traits/is_invocable.md)に対応する。 + + +## 戻り値 +`type`が`type_args`で指定された引数型で呼び出し可能な場合に`true`を返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +void f(int, double) {} + +int main() { + static_assert(std::meta::is_invocable_type(^^decltype(f), {^^int, ^^double})); + static_assert(!std::meta::is_invocable_type(^^decltype(f), {^^int})); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_invocable`](/reference/type_traits/is_invocable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_layout_compatible_type.md b/reference/meta/is_layout_compatible_type.md new file mode 100644 index 0000000000..acc76bd023 --- /dev/null +++ b/reference/meta/is_layout_compatible_type.md @@ -0,0 +1,58 @@ +# is_layout_compatible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_layout_compatible_type(info type1, info type2); +} +``` +* info[link info.md] + +## 概要 +2つの型がレイアウト互換かを判定する。[`std::is_layout_compatible`](/reference/type_traits/is_layout_compatible.md)に対応する。 + + +## 戻り値 +`type1`と`type2`がレイアウト互換である場合に`true`を返す。 + + +## 例外 +`type1`または`type2`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct A { int x; }; +struct B { int y; }; + +int main() { + static_assert(std::meta::is_layout_compatible_type(^^A, ^^B)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_layout_compatible`](/reference/type_traits/is_layout_compatible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_literal_operator.md b/reference/meta/is_literal_operator.md new file mode 100644 index 0000000000..d24332ee0a --- /dev/null +++ b/reference/meta/is_literal_operator.md @@ -0,0 +1,55 @@ +# is_literal_operator +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_literal_operator(info r); +} +``` +* info[link info.md] + +## 概要 +リテラル演算子であるかを判定する。リテラル演算子とは、ユーザー定義リテラル(`123_km`のような接尾辞付きリテラル)を定義するための`operator"" _suffix`形式の関数である。 + + +## 戻り値 +`r`がリテラル演算子を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +// リテラル演算子 +long double operator""_km(long double val) { return val * 1000.0L; } + +// 通常の関数 +double to_meters(double km) { return km * 1000.0; } + +int main() { + static_assert(std::meta::is_literal_operator(^^operator""_km)); + static_assert(!std::meta::is_literal_operator(^^to_meters)); +} +``` +* std::meta::is_literal_operator[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_literal_operator_template.md b/reference/meta/is_literal_operator_template.md new file mode 100644 index 0000000000..299d30714d --- /dev/null +++ b/reference/meta/is_literal_operator_template.md @@ -0,0 +1,67 @@ +# is_literal_operator_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_literal_operator_template(info r); +} +``` +* info[link info.md] + +## 概要 +リテラル演算子テンプレートであるかを判定する。 + +リテラル演算子テンプレートとは、`template operator""_suffix()`のようなテンプレート化されたユーザー定義リテラル演算子のことである。 + + +## 戻り値 +`r`がリテラル演算子テンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +// リテラル演算子(テンプレートではない) +long double operator""_km(long double val) { return val * 1000.0L; } + +// リテラル演算子テンプレート +template +constexpr unsigned operator""_b() { + unsigned result = 0; + for (char c : {Chars...}) { + result = result * 2 + (c - '0'); + } + return result; +} + +int main() { + static_assert(std::meta::is_literal_operator_template(^^operator""_b)); + static_assert(!std::meta::is_literal_operator_template(^^operator""_km)); + + // どちらもリテラル演算子ではある + static_assert(std::meta::is_literal_operator(^^operator""_km)); +} +``` +* std::meta::is_literal_operator[link is_literal_operator.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_lvalue_reference_qualified.md b/reference/meta/is_lvalue_reference_qualified.md new file mode 100644 index 0000000000..8f2f1c37cd --- /dev/null +++ b/reference/meta/is_lvalue_reference_qualified.md @@ -0,0 +1,55 @@ +# is_lvalue_reference_qualified +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_lvalue_reference_qualified(info r); +} +``` +* info[link info.md] + +## 概要 +左辺値参照修飾されているかを判定する。 + + +## 戻り値 +`r`が`&`参照修飾されたメンバ関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + void f() & {} + void g() && {} + void h() {} +}; + +int main() { + static_assert(std::meta::is_lvalue_reference_qualified(^^S::f)); + static_assert(!std::meta::is_lvalue_reference_qualified(^^S::g)); + static_assert(!std::meta::is_lvalue_reference_qualified(^^S::h)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_lvalue_reference_type.md b/reference/meta/is_lvalue_reference_type.md new file mode 100644 index 0000000000..bf7677b9da --- /dev/null +++ b/reference/meta/is_lvalue_reference_type.md @@ -0,0 +1,55 @@ +# is_lvalue_reference_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_lvalue_reference_type(info type); +} +``` +* info[link info.md] + +## 概要 +左辺値参照型であるかを判定する。 + + +## 戻り値 +`type`が左辺値参照型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_lvalue_reference_type(^^int&)); + static_assert(!std::meta::is_lvalue_reference_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_lvalue_reference`](/reference/type_traits/is_lvalue_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_member_function_pointer_type.md b/reference/meta/is_member_function_pointer_type.md new file mode 100644 index 0000000000..4d4915df24 --- /dev/null +++ b/reference/meta/is_member_function_pointer_type.md @@ -0,0 +1,59 @@ +# is_member_function_pointer_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_member_function_pointer_type(info type); +} +``` +* info[link info.md] + +## 概要 +メンバ関数ポインタ型であるかを判定する。 + + +## 戻り値 +`type`がメンバ関数ポインタ型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct S { void f() {} }; + +int main() { + // メンバ関数ポインタ型のリフレクションで判定 + using MFP = void (S::*)(); + static_assert(std::meta::is_member_function_pointer_type(^^MFP)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_member_function_pointer`](/reference/type_traits/is_member_function_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_member_object_pointer_type.md b/reference/meta/is_member_object_pointer_type.md new file mode 100644 index 0000000000..9a0456292f --- /dev/null +++ b/reference/meta/is_member_object_pointer_type.md @@ -0,0 +1,58 @@ +# is_member_object_pointer_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_member_object_pointer_type(info type); +} +``` +* info[link info.md] + +## 概要 +メンバオブジェクトポインタ型であるかを判定する。 + + +## 戻り値 +`type`がメンバオブジェクトポインタ型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct S { int x; void f() {} }; + +int main() { + static_assert(std::meta::is_member_object_pointer_type(^^int S::*) == std::is_member_object_pointer_v); +} +``` +* std::is_member_object_pointer_v[link /reference/type_traits/is_member_object_pointer.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_member_object_pointer`](/reference/type_traits/is_member_object_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_member_pointer_type.md b/reference/meta/is_member_pointer_type.md new file mode 100644 index 0000000000..85669bff92 --- /dev/null +++ b/reference/meta/is_member_pointer_type.md @@ -0,0 +1,57 @@ +# is_member_pointer_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_member_pointer_type(info type); +} +``` +* info[link info.md] + +## 概要 +メンバポインタ型であるかを判定する。 + + +## 戻り値 +`type`がメンバポインタ型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +struct S { int x; }; + +int main() { + static_assert(std::meta::is_member_pointer_type(^^int S::*)); + static_assert(!std::meta::is_member_pointer_type(^^int*)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_member_pointer`](/reference/type_traits/is_member_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_move_assignable_type.md b/reference/meta/is_move_assignable_type.md new file mode 100644 index 0000000000..9a01bc85cc --- /dev/null +++ b/reference/meta/is_move_assignable_type.md @@ -0,0 +1,65 @@ +# is_move_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_move_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +ムーブ代入可能型であるかを判定する。[`std::is_move_assignable`](/reference/type_traits/is_move_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型がムーブ代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct CopyOnly { + CopyOnly& operator=(const CopyOnly&) = default; + CopyOnly& operator=(CopyOnly&&) = delete; +}; + +int main() { + static_assert(std::meta::is_move_assignable_type(^^int)); + static_assert(std::meta::is_move_assignable_type(^^std::unique_ptr)); + static_assert(!std::meta::is_move_assignable_type(^^CopyOnly)); + static_assert(!std::meta::is_move_assignable_type(^^const int)); +} +``` +* std::meta::is_move_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_move_assignable`](/reference/type_traits/is_move_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_move_assignment.md b/reference/meta/is_move_assignment.md new file mode 100644 index 0000000000..4f1bfed50b --- /dev/null +++ b/reference/meta/is_move_assignment.md @@ -0,0 +1,63 @@ +# is_move_assignment +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_move_assignment(info r); +} +``` +* info[link info.md] + +## 概要 +ムーブ代入演算子であるかを判定する。 + + +## 戻り値 +`r`がムーブ代入演算子を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S& operator=(const S&) = default; // コピー代入演算子 + S& operator=(S&&) = default; // ムーブ代入演算子 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_move_assignment(m)) { + static_assert(!std::meta::is_copy_assignment(m)); + static_assert(std::meta::is_assignment(m)); + } + } +} +``` +* std::meta::is_copy_assignment[link is_copy_assignment.md] +* std::meta::is_assignment[link is_assignment.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_move_constructible_type.md b/reference/meta/is_move_constructible_type.md new file mode 100644 index 0000000000..aeedc63683 --- /dev/null +++ b/reference/meta/is_move_constructible_type.md @@ -0,0 +1,64 @@ +# is_move_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_move_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +ムーブ構築可能型であるかを判定する。[`std::is_move_constructible`](/reference/type_traits/is_move_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がムーブ構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct CopyOnly { + CopyOnly(const CopyOnly&) = default; + CopyOnly(CopyOnly&&) = delete; +}; + +int main() { + static_assert(std::meta::is_move_constructible_type(^^int)); + static_assert(std::meta::is_move_constructible_type(^^std::unique_ptr)); + static_assert(!std::meta::is_move_constructible_type(^^CopyOnly)); +} +``` +* std::meta::is_move_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_move_constructible`](/reference/type_traits/is_move_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_move_constructor.md b/reference/meta/is_move_constructor.md new file mode 100644 index 0000000000..8d2a16ab56 --- /dev/null +++ b/reference/meta/is_move_constructor.md @@ -0,0 +1,68 @@ +# is_move_constructor +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_move_constructor(info r); +} +``` +* info[link info.md] + +## 概要 +ムーブコンストラクタであるかを判定する。 + + +## 戻り値 +`r`がムーブコンストラクタを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; + S(const S&) = default; // コピーコンストラクタ + S(S&&) = default; // ムーブコンストラクタ +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_move_constructor(m)) { + // S(S&&)のみがここに到達する + static_assert(std::meta::is_constructor(m)); + static_assert(!std::meta::is_copy_constructor(m)); + static_assert(std::meta::is_special_member_function(m)); + } + } +} +``` +* std::meta::is_move_constructor[color ff0000] +* std::meta::is_constructor[link is_constructor.md] +* std::meta::is_copy_constructor[link is_copy_constructor.md] +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_mutable_member.md b/reference/meta/is_mutable_member.md new file mode 100644 index 0000000000..d475d21c5d --- /dev/null +++ b/reference/meta/is_mutable_member.md @@ -0,0 +1,53 @@ +# is_mutable_member +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_mutable_member(info r); +} +``` +* info[link info.md] + +## 概要 +`mutable`メンバであるかを判定する。 + + +## 戻り値 +`r`が`mutable`指定されたデータメンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int x; + mutable int y; +}; + +int main() { + static_assert(!std::meta::is_mutable_member(^^S::x)); + static_assert(std::meta::is_mutable_member(^^S::y)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_namespace.md b/reference/meta/is_namespace.md new file mode 100644 index 0000000000..47e8ffb2ba --- /dev/null +++ b/reference/meta/is_namespace.md @@ -0,0 +1,51 @@ +# is_namespace +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_namespace(info r); +} +``` +* info[link info.md] + +## 概要 +名前空間であるかを判定する。 + + +## 戻り値 +`r`が名前空間を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +namespace my_ns {} + +int main() { + static_assert(std::meta::is_namespace(^^std)); + static_assert(std::meta::is_namespace(^^my_ns)); + static_assert(!std::meta::is_namespace(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_namespace_alias.md b/reference/meta/is_namespace_alias.md new file mode 100644 index 0000000000..6d4e79c282 --- /dev/null +++ b/reference/meta/is_namespace_alias.md @@ -0,0 +1,51 @@ +# is_namespace_alias +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_namespace_alias(info r); +} +``` +* info[link info.md] + +## 概要 +名前空間エイリアスであるかを判定する。 + + +## 戻り値 +`r`が名前空間エイリアスを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +namespace my_ns {} +namespace alias_ns = my_ns; // 名前空間の別名 + +int main() { + static_assert(std::meta::is_namespace_alias(^^alias_ns)); + static_assert(!std::meta::is_namespace_alias(^^my_ns)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_namespace_member.md b/reference/meta/is_namespace_member.md new file mode 100644 index 0000000000..b9f438303f --- /dev/null +++ b/reference/meta/is_namespace_member.md @@ -0,0 +1,51 @@ +# is_namespace_member +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_namespace_member(info r); +} +``` +* info[link info.md] + +## 概要 +名前空間メンバであるかを判定する。 + + +## 戻り値 +`r`が名前空間のメンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +namespace ns { + int x; +} + +int main() { + static_assert(std::meta::is_namespace_member(^^ns::x)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_noexcept.md b/reference/meta/is_noexcept.md new file mode 100644 index 0000000000..02e674d19c --- /dev/null +++ b/reference/meta/is_noexcept.md @@ -0,0 +1,51 @@ +# is_noexcept +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_noexcept(info r); +} +``` +* info[link info.md] + +## 概要 +`noexcept`であるかを判定する。 + + +## 戻り値 +`r`が`noexcept`指定された関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +void f1() noexcept {} +void f2() {} + +int main() { + static_assert(std::meta::is_noexcept(^^f1)); + static_assert(!std::meta::is_noexcept(^^f2)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nonstatic_data_member.md b/reference/meta/is_nonstatic_data_member.md new file mode 100644 index 0000000000..c1782ff756 --- /dev/null +++ b/reference/meta/is_nonstatic_data_member.md @@ -0,0 +1,53 @@ +# is_nonstatic_data_member +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nonstatic_data_member(info r); +} +``` +* info[link info.md] + +## 概要 +非静的データメンバであるかを判定する。 + + +## 戻り値 +`r`が非静的データメンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int x; + static int y; +}; + +int main() { + static_assert(std::meta::is_nonstatic_data_member(^^S::x)); + static_assert(!std::meta::is_nonstatic_data_member(^^S::y)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_assignable_type.md b/reference/meta/is_nothrow_assignable_type.md new file mode 100644 index 0000000000..24e4298746 --- /dev/null +++ b/reference/meta/is_nothrow_assignable_type.md @@ -0,0 +1,64 @@ +# is_nothrow_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_assignable_type(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずに代入可能かを判定する。[`std::is_nothrow_assignable`](/reference/type_traits/is_nothrow_assignable.md)に対応する。 + + +## 戻り値 +`type_dst`と`type_src`が表す型について、例外を送出せずに代入可能な場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct A {}; +struct B { + B& operator=(const A&) noexcept { return *this; } +}; +struct C { + C& operator=(const A&) noexcept(false) { return *this; } +}; + +int main() { + static_assert(std::meta::is_nothrow_assignable_type(^^int&, ^^int)); + // B::operator=(const A&)はnoexcept + static_assert(std::meta::is_nothrow_assignable_type(^^B&, ^^const A&)); + // C::operator=(const A&)はnoexcept(false) + static_assert(!std::meta::is_nothrow_assignable_type(^^C&, ^^const A&)); +} +``` +* std::meta::is_nothrow_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_constructible_type.md b/reference/meta/is_nothrow_constructible_type.md new file mode 100644 index 0000000000..1f0ba43bdc --- /dev/null +++ b/reference/meta/is_nothrow_constructible_type.md @@ -0,0 +1,64 @@ +# is_nothrow_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_nothrow_constructible_type(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +例外を送出せずに構築可能かを判定する。[`std::is_nothrow_constructible`](/reference/type_traits/is_nothrow_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が`type_args`で指定された引数型で例外を送出せずに構築可能な場合に`true`を返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Safe { + Safe(int, double) noexcept {} +}; + +struct Throwing { + Throwing(int, double) noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_constructible_type(^^int, {^^int})); + static_assert(std::meta::is_nothrow_constructible_type(^^Safe, {^^int, ^^double})); + static_assert(!std::meta::is_nothrow_constructible_type(^^Throwing, {^^int, ^^double})); +} +``` +* std::meta::is_nothrow_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_convertible_type.md b/reference/meta/is_nothrow_convertible_type.md new file mode 100644 index 0000000000..605070b18b --- /dev/null +++ b/reference/meta/is_nothrow_convertible_type.md @@ -0,0 +1,66 @@ +# is_nothrow_convertible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_convertible_type(info type_src, info type_dst); +} +``` +* info[link info.md] + +## 概要 +型が別の型に例外を送出せずに変換可能かを判定する。[`std::is_nothrow_convertible`](/reference/type_traits/is_nothrow_convertible.md)に対応する。 + + +## 戻り値 +`type_src`が`type_dst`に例外を送出せずに変換可能な場合に`true`を返す。 + + +## 例外 +`type_src`または`type_dst`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct A {}; +struct B { + B(const A&) noexcept {} +}; +struct C { + C(const A&) noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_convertible_type(^^int, ^^double)); + static_assert(std::meta::is_nothrow_convertible_type(^^A, ^^B)); + static_assert(!std::meta::is_nothrow_convertible_type(^^A, ^^C)); +} +``` +* std::meta::is_nothrow_convertible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_convertible`](/reference/type_traits/is_nothrow_convertible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_copy_assignable_type.md b/reference/meta/is_nothrow_copy_assignable_type.md new file mode 100644 index 0000000000..ced9bc61ad --- /dev/null +++ b/reference/meta/is_nothrow_copy_assignable_type.md @@ -0,0 +1,66 @@ +# is_nothrow_copy_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_copy_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにコピー代入可能型であるかを判定する。[`std::is_nothrow_copy_assignable`](/reference/type_traits/is_nothrow_copy_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにコピー代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Safe { + Safe& operator=(const Safe&) noexcept = default; +}; + +struct Throwing { + Throwing& operator=(const Throwing&) noexcept(false) { return *this; } +}; + +int main() { + static_assert(std::meta::is_nothrow_copy_assignable_type(^^int)); + static_assert(std::meta::is_nothrow_copy_assignable_type(^^Safe)); + static_assert(!std::meta::is_nothrow_copy_assignable_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_copy_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_copy_assignable`](/reference/type_traits/is_nothrow_copy_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_copy_constructible_type.md b/reference/meta/is_nothrow_copy_constructible_type.md new file mode 100644 index 0000000000..469f794323 --- /dev/null +++ b/reference/meta/is_nothrow_copy_constructible_type.md @@ -0,0 +1,61 @@ +# is_nothrow_copy_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_copy_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにコピー構築可能型であるかを判定する。[`std::is_nothrow_copy_constructible`](/reference/type_traits/is_nothrow_copy_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにコピー構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Throwing { + Throwing(const Throwing&) noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_copy_constructible_type(^^int)); + static_assert(!std::meta::is_nothrow_copy_constructible_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_copy_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_copy_constructible`](/reference/type_traits/is_nothrow_copy_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_default_constructible_type.md b/reference/meta/is_nothrow_default_constructible_type.md new file mode 100644 index 0000000000..5c4a342e8b --- /dev/null +++ b/reference/meta/is_nothrow_default_constructible_type.md @@ -0,0 +1,66 @@ +# is_nothrow_default_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_default_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにデフォルト構築可能型であるかを判定する。[`std::is_nothrow_default_constructible`](/reference/type_traits/is_nothrow_default_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにデフォルト構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Throwing { + Throwing() noexcept(false) {} +}; + +struct Safe { + Safe() noexcept = default; +}; + +int main() { + static_assert(std::meta::is_nothrow_default_constructible_type(^^int)); + static_assert(std::meta::is_nothrow_default_constructible_type(^^Safe)); + static_assert(!std::meta::is_nothrow_default_constructible_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_default_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_default_constructible`](/reference/type_traits/is_nothrow_default_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_destructible_type.md b/reference/meta/is_nothrow_destructible_type.md new file mode 100644 index 0000000000..a96bdd7070 --- /dev/null +++ b/reference/meta/is_nothrow_destructible_type.md @@ -0,0 +1,61 @@ +# is_nothrow_destructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_destructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずに破棄可能型であるかを判定する。[`std::is_nothrow_destructible`](/reference/type_traits/is_nothrow_destructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずに破棄可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Throwing { + ~Throwing() noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_destructible_type(^^int)); + static_assert(!std::meta::is_nothrow_destructible_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_destructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_destructible`](/reference/type_traits/is_nothrow_destructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_invocable_r_type.md b/reference/meta/is_nothrow_invocable_r_type.md new file mode 100644 index 0000000000..2cb8027167 --- /dev/null +++ b/reference/meta/is_nothrow_invocable_r_type.md @@ -0,0 +1,63 @@ +# is_nothrow_invocable_r_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_nothrow_invocable_r_type(info type_result, info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + + +## 概要 +例外を送出せずに呼び出し可能で戻り値が指定型に変換可能かを判定する。[`std::is_nothrow_invocable_r`](/reference/type_traits/is_nothrow_invocable_r.md)に対応する。 + + +## 戻り値 +`type`が`type_args`で例外を送出せずに呼び出し可能で、戻り値が`type_result`に変換可能な場合に`true`を返す。 + + +## 例外 +`type_result`、`type`、または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int f(double) noexcept { return 0; } +int g(double) { return 0; } // noexceptでない + +int main() { + static_assert(std::meta::is_nothrow_invocable_r_type(^^int, ^^decltype(f), {^^double})); + static_assert(!std::meta::is_nothrow_invocable_r_type(^^int, ^^decltype(g), {^^double})); +} +``` +* std::meta::is_nothrow_invocable_r_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_invocable_r`](/reference/type_traits/is_nothrow_invocable_r.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_invocable_type.md b/reference/meta/is_nothrow_invocable_type.md new file mode 100644 index 0000000000..63bbc9272f --- /dev/null +++ b/reference/meta/is_nothrow_invocable_type.md @@ -0,0 +1,62 @@ +# is_nothrow_invocable_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_nothrow_invocable_type(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + + +## 概要 +例外を送出せずに呼び出し可能かを判定する。[`std::is_nothrow_invocable`](/reference/type_traits/is_nothrow_invocable.md)に対応する。 + + +## 戻り値 +`type`が`type_args`で例外を送出せずに呼び出し可能な場合に`true`を返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +void f(int) noexcept {} +void g(int) {} + +int main() { + static_assert(std::meta::is_nothrow_invocable_type(^^decltype(f), {^^int})); + static_assert(!std::meta::is_nothrow_invocable_type(^^decltype(g), {^^int})); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_invocable`](/reference/type_traits/is_nothrow_invocable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_move_assignable_type.md b/reference/meta/is_nothrow_move_assignable_type.md new file mode 100644 index 0000000000..a2adcb91fb --- /dev/null +++ b/reference/meta/is_nothrow_move_assignable_type.md @@ -0,0 +1,63 @@ +# is_nothrow_move_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_move_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにムーブ代入可能型であるかを判定する。[`std::is_nothrow_move_assignable`](/reference/type_traits/is_nothrow_move_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにムーブ代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Throwing { + Throwing& operator=(Throwing&&) noexcept(false) { return *this; } +}; + +int main() { + static_assert(std::meta::is_nothrow_move_assignable_type(^^int)); + static_assert(std::meta::is_nothrow_move_assignable_type(^^std::string)); + static_assert(!std::meta::is_nothrow_move_assignable_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_move_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_move_assignable`](/reference/type_traits/is_nothrow_move_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_move_constructible_type.md b/reference/meta/is_nothrow_move_constructible_type.md new file mode 100644 index 0000000000..ce3724d0ad --- /dev/null +++ b/reference/meta/is_nothrow_move_constructible_type.md @@ -0,0 +1,65 @@ +# is_nothrow_move_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_move_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにムーブ構築可能型であるかを判定する。[`std::is_nothrow_move_constructible`](/reference/type_traits/is_nothrow_move_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにムーブ構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include +#include + +struct Throwing { + Throwing(Throwing&&) noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_move_constructible_type(^^int)); + static_assert(std::meta::is_nothrow_move_constructible_type(^^std::string)); + static_assert(std::meta::is_nothrow_move_constructible_type(^^std::vector)); + static_assert(!std::meta::is_nothrow_move_constructible_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_move_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_move_constructible`](/reference/type_traits/is_nothrow_move_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_swappable_type.md b/reference/meta/is_nothrow_swappable_type.md new file mode 100644 index 0000000000..e44c73bd88 --- /dev/null +++ b/reference/meta/is_nothrow_swappable_type.md @@ -0,0 +1,66 @@ +# is_nothrow_swappable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_swappable_type(info type); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずにswap可能型であるかを判定する。[`std::is_nothrow_swappable`](/reference/type_traits/is_nothrow_swappable.md)に対応する。 + + +## 戻り値 +`type`が表す型が例外を送出せずにswap可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Safe { + friend void swap(Safe&, Safe&) noexcept {} +}; + +struct Throwing { + friend void swap(Throwing&, Throwing&) noexcept(false) {} +}; + +int main() { + static_assert(std::meta::is_nothrow_swappable_type(^^int)); + static_assert(std::meta::is_nothrow_swappable_type(^^Safe)); + static_assert(!std::meta::is_nothrow_swappable_type(^^Throwing)); +} +``` +* std::meta::is_nothrow_swappable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_nothrow_swappable`](/reference/type_traits/is_nothrow_swappable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_nothrow_swappable_with_type.md b/reference/meta/is_nothrow_swappable_with_type.md new file mode 100644 index 0000000000..bec60539c6 --- /dev/null +++ b/reference/meta/is_nothrow_swappable_with_type.md @@ -0,0 +1,64 @@ +# is_nothrow_swappable_with_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_nothrow_swappable_with_type(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +例外を送出せずに指定した2つの型の間でswap可能かを判定する。[`std::is_nothrow_swappable_with`](/reference/type_traits/is_nothrow_swappable_with.md)に対応する。 + + +## 戻り値 +`type_dst`と`type_src`が表す型の間で例外を送出せずにswap可能な場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct A {}; +struct B {}; +void swap(A&, B&) noexcept {} +void swap(B&, A&) noexcept {} + +struct X {}; +struct Y {}; +void swap(X&, Y&) noexcept(false) {} +void swap(Y&, X&) noexcept(false) {} + +int main() { + static_assert(std::meta::is_nothrow_swappable_with_type(^^A&, ^^B&)); + static_assert(!std::meta::is_nothrow_swappable_with_type(^^X&, ^^Y&)); +} +``` +* std::meta::is_nothrow_swappable_with_type[color ff0000] +* std::meta::is_nothrow_swappable_with_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_null_pointer_type.md b/reference/meta/is_null_pointer_type.md new file mode 100644 index 0000000000..ce002f133a --- /dev/null +++ b/reference/meta/is_null_pointer_type.md @@ -0,0 +1,55 @@ +# is_null_pointer_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_null_pointer_type(info type); +} +``` +* info[link info.md] + +## 概要 +`nullptr_t`型(CV修飾を含む)であるかを判定する。 + + +## 戻り値 +`type`が`nullptr_t`型(CV修飾を含む)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_null_pointer_type(^^std::nullptr_t)); + static_assert(!std::meta::is_null_pointer_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_null_pointer`](/reference/type_traits/is_null_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_object.md b/reference/meta/is_object.md new file mode 100644 index 0000000000..7f4fe375e7 --- /dev/null +++ b/reference/meta/is_object.md @@ -0,0 +1,50 @@ +# is_object +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_object(info r); +} +``` +* info[link info.md] + +## 概要 +オブジェクトであるかを判定する。 + + +## 戻り値 +`r`がオブジェクトを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +static int obj = 0; + +int main() { + constexpr auto r = std::meta::object_of(^^obj); + static_assert(std::meta::is_object(r)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_object_type.md b/reference/meta/is_object_type.md new file mode 100644 index 0000000000..82a20b3d17 --- /dev/null +++ b/reference/meta/is_object_type.md @@ -0,0 +1,55 @@ +# is_object_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_object_type(info type); +} +``` +* info[link info.md] + +## 概要 +オブジェクト型であるかを判定する。 + + +## 戻り値 +`type`がオブジェクト型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_object_type(^^int)); + static_assert(!std::meta::is_object_type(^^int&)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_object`](/reference/type_traits/is_object.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_operator_function.md b/reference/meta/is_operator_function.md new file mode 100644 index 0000000000..6eca87b954 --- /dev/null +++ b/reference/meta/is_operator_function.md @@ -0,0 +1,73 @@ +# is_operator_function +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_operator_function(info r); +} +``` +* info[link info.md] + +## 概要 +演算子関数(`operator+`、`operator==`など、`operator`キーワードで定義される関数)であるかを判定する。代入演算子`operator=`も演算子関数に含まれる。 + + +## 戻り値 +`r`が演算子関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + int value; + S operator+(const S& other) const { return {value + other.value}; } + bool operator==(const S&) const = default; + void f() {} // 通常のメンバ関数 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_function(m) && + !std::meta::is_special_member_function(m)) { + std::println("{}: is_operator_function={}", + std::meta::display_string_of(m), + std::meta::is_operator_function(m)); + } + } +} +``` +* std::meta::is_operator_function[color ff0000] +* std::meta::is_function[link is_function.md] +* std::meta::is_special_member_function[link is_special_member_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::display_string_of[link display_string_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +S::operator+(const S&): is_operator_function=true +S::operator==(const S&): is_operator_function=true +S::f(): is_operator_function=false +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_operator_function_template.md b/reference/meta/is_operator_function_template.md new file mode 100644 index 0000000000..609b435583 --- /dev/null +++ b/reference/meta/is_operator_function_template.md @@ -0,0 +1,67 @@ +# is_operator_function_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_operator_function_template(info r); +} +``` +* info[link info.md] + +## 概要 +演算子関数テンプレートであるかを判定する。演算子関数テンプレートとは、`template bool operator==(const T&)`のようなテンプレート化された演算子関数のことである。 + + +## 戻り値 +`r`が演算子関数テンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + bool operator==(const S&) const = default; // 演算子関数 + template + S operator+(const T& other) const { return *this; } // 演算子関数テンプレート + void f() {} // 通常のメンバ関数 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_operator_function_template(m)) { + // template operator+(const T&) のみがここに到達する + static_assert(std::meta::is_template(m)); + static_assert(!std::meta::is_operator_function(m)); + } + } +} +``` +* std::meta::is_operator_function_template[color ff0000] +* std::meta::is_template[link is_template.md] +* std::meta::is_operator_function[link is_operator_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_override.md b/reference/meta/is_override.md new file mode 100644 index 0000000000..50b4d28e7b --- /dev/null +++ b/reference/meta/is_override.md @@ -0,0 +1,63 @@ +# is_override +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_override(info r); +} +``` +* info[link info.md] + +## 概要 +基底クラスの仮想関数をオーバーライドしているメンバ関数であるかを判定する。`override`キーワードの有無に関係なく、意味的にオーバーライドしていれば`true`を返す。 + + +## 戻り値 +`r`が別のメンバ関数をオーバーライドしているメンバ関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Base { + virtual void f() {} + virtual void g() {} +}; + +struct Derived : Base { + void f() override {} // overrideキーワードあり + void g() {} // overrideキーワードなしだが、オーバーライドしている +}; + +int main() { + // 基底クラスの仮想関数はオーバーライドではない + static_assert(!std::meta::is_override(^^Base::f)); + + // overrideキーワードの有無に関係なく、オーバーライドしていればtrue + static_assert(std::meta::is_override(^^Derived::f)); + static_assert(std::meta::is_override(^^Derived::g)); +} +``` +* std::meta::is_override[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_pointer_interconvertible_base_of_type.md b/reference/meta/is_pointer_interconvertible_base_of_type.md new file mode 100644 index 0000000000..e5f6cd8743 --- /dev/null +++ b/reference/meta/is_pointer_interconvertible_base_of_type.md @@ -0,0 +1,58 @@ +# is_pointer_interconvertible_base_of_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_pointer_interconvertible_base_of_type(info type_base, info type_derived); +} +``` +* info[link info.md] + +## 概要 +基底クラスがポインタ相互変換可能かを判定する。[`std::is_pointer_interconvertible_base_of`](/reference/type_traits/is_pointer_interconvertible_base_of.md)に対応する。 + + +## 戻り値 +`type_base`が`type_derived`のポインタ相互変換可能な基底クラスである場合に`true`を返す。 + + +## 例外 +`type_base`または`type_derived`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Base { int x; }; +struct Derived : Base {}; + +int main() { + static_assert(std::meta::is_pointer_interconvertible_base_of_type(^^Base, ^^Derived)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_pointer_interconvertible_base_of`](/reference/type_traits/is_pointer_interconvertible_base_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_pointer_type.md b/reference/meta/is_pointer_type.md new file mode 100644 index 0000000000..18456f5a78 --- /dev/null +++ b/reference/meta/is_pointer_type.md @@ -0,0 +1,55 @@ +# is_pointer_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_pointer_type(info type); +} +``` +* info[link info.md] + +## 概要 +ポインタ型であるかを判定する。 + + +## 戻り値 +`type`がポインタ型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_pointer_type(^^int*)); + static_assert(!std::meta::is_pointer_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_pointer`](/reference/type_traits/is_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_polymorphic_type.md b/reference/meta/is_polymorphic_type.md new file mode 100644 index 0000000000..b24487ddd3 --- /dev/null +++ b/reference/meta/is_polymorphic_type.md @@ -0,0 +1,57 @@ +# is_polymorphic_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_polymorphic_type(info type); +} +``` +* info[link info.md] + +## 概要 +多態的型であるかを判定する。 + + +## 戻り値 +`type`が仮想関数を持つクラス型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Poly { virtual void f() {} }; + +int main() { + static_assert(std::meta::is_polymorphic_type(^^Poly)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_polymorphic`](/reference/type_traits/is_polymorphic.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_private.md b/reference/meta/is_private.md new file mode 100644 index 0000000000..88ea92f378 --- /dev/null +++ b/reference/meta/is_private.md @@ -0,0 +1,64 @@ +# is_private +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_private(info r); +} +``` +* info[link info.md] + +## 概要 +`private`アクセスであるかを判定する。 + + +## 戻り値 +`r`がクラスメンバまたは基底クラス関係を表し、かつ`private`アクセスである場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int pub; +protected: + int prot; +private: + int priv; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^S, std::meta::access_context::unchecked()); + static_assert(std::meta::is_public(members[0])); + static_assert(std::meta::is_protected(members[1])); + static_assert(std::meta::is_private(members[2])); +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::is_public[link is_public.md] +* std::meta::is_protected[link is_protected.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_protected.md b/reference/meta/is_protected.md new file mode 100644 index 0000000000..f422b84a0a --- /dev/null +++ b/reference/meta/is_protected.md @@ -0,0 +1,64 @@ +# is_protected +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_protected(info r); +} +``` +* info[link info.md] + +## 概要 +`protected`アクセスであるかを判定する。 + + +## 戻り値 +`r`がクラスメンバまたは基底クラス関係を表し、かつ`protected`アクセスである場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int pub; +protected: + int prot; +private: + int priv; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^S, std::meta::access_context::unchecked()); + static_assert(std::meta::is_public(members[0])); + static_assert(std::meta::is_protected(members[1])); + static_assert(std::meta::is_private(members[2])); +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::is_public[link is_public.md] +* std::meta::is_private[link is_private.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_public.md b/reference/meta/is_public.md new file mode 100644 index 0000000000..d1ab6d481e --- /dev/null +++ b/reference/meta/is_public.md @@ -0,0 +1,64 @@ +# is_public +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_public(info r); +} +``` +* info[link info.md] + +## 概要 +`public`アクセスであるかを判定する。 + + +## 戻り値 +`r`がクラスメンバまたは基底クラス関係を表し、かつ`public`アクセスである場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int pub; +protected: + int prot; +private: + int priv; +}; + +int main() { + constexpr auto members = std::meta::nonstatic_data_members_of( + ^^S, std::meta::access_context::unchecked()); + static_assert(std::meta::is_public(members[0])); + static_assert(std::meta::is_protected(members[1])); + static_assert(std::meta::is_private(members[2])); +} +``` +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::is_protected[link is_protected.md] +* std::meta::is_private[link is_private.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_pure_virtual.md b/reference/meta/is_pure_virtual.md new file mode 100644 index 0000000000..c7b0d9b6d6 --- /dev/null +++ b/reference/meta/is_pure_virtual.md @@ -0,0 +1,53 @@ +# is_pure_virtual +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_pure_virtual(info r); +} +``` +* info[link info.md] + +## 概要 +純粋仮想関数であるかを判定する。 + + +## 戻り値 +`r`が純粋仮想関数(`= 0`)を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Interface { + virtual void f() = 0; + virtual void g() {} +}; + +int main() { + static_assert(std::meta::is_pure_virtual(^^Interface::f)); + static_assert(!std::meta::is_pure_virtual(^^Interface::g)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_reference_type.md b/reference/meta/is_reference_type.md new file mode 100644 index 0000000000..e9f340570f --- /dev/null +++ b/reference/meta/is_reference_type.md @@ -0,0 +1,55 @@ +# is_reference_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_reference_type(info type); +} +``` +* info[link info.md] + +## 概要 +参照型であるかを判定する。 + + +## 戻り値 +`type`が参照型(左辺値参照または右辺値参照)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_reference_type(^^int&)); + static_assert(!std::meta::is_reference_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_reference`](/reference/type_traits/is_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_reflection_type.md b/reference/meta/is_reflection_type.md new file mode 100644 index 0000000000..36b2408b89 --- /dev/null +++ b/reference/meta/is_reflection_type.md @@ -0,0 +1,51 @@ +# is_reflection_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_reflection_type(info type); +} +``` +* info[link info.md] + +## 概要 +リフレクション型であるかを判定する。 + + +## 戻り値 +`type`がリフレクション型(`std::meta::info`)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_reflection_type(^^std::meta::info)); + static_assert(!std::meta::is_reflection_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_rvalue_reference_qualified.md b/reference/meta/is_rvalue_reference_qualified.md new file mode 100644 index 0000000000..b61535c4ec --- /dev/null +++ b/reference/meta/is_rvalue_reference_qualified.md @@ -0,0 +1,53 @@ +# is_rvalue_reference_qualified +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_rvalue_reference_qualified(info r); +} +``` +* info[link info.md] + +## 概要 +右辺値参照修飾されているかを判定する。 + + +## 戻り値 +`r`が`&&`参照修飾されたメンバ関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + void f() & {} + void g() && {} +}; + +int main() { + static_assert(!std::meta::is_rvalue_reference_qualified(^^S::f)); + static_assert(std::meta::is_rvalue_reference_qualified(^^S::g)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_rvalue_reference_type.md b/reference/meta/is_rvalue_reference_type.md new file mode 100644 index 0000000000..a5005a16d7 --- /dev/null +++ b/reference/meta/is_rvalue_reference_type.md @@ -0,0 +1,55 @@ +# is_rvalue_reference_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_rvalue_reference_type(info type); +} +``` +* info[link info.md] + +## 概要 +右辺値参照型であるかを判定する。 + + +## 戻り値 +`type`が右辺値参照型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_rvalue_reference_type(^^int&&)); + static_assert(!std::meta::is_rvalue_reference_type(^^int&)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_rvalue_reference`](/reference/type_traits/is_rvalue_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_same_type.md b/reference/meta/is_same_type.md new file mode 100644 index 0000000000..59d5a3abad --- /dev/null +++ b/reference/meta/is_same_type.md @@ -0,0 +1,56 @@ +# is_same_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_same_type(info type1, info type2); +} +``` +* info[link info.md] + +## 概要 +2つの型が同じかを判定する。[`std::is_same`](/reference/type_traits/is_same.md)に対応する。 + + +## 戻り値 +`type1`と`type2`が同じ型を表す場合に`true`を返す。 + + +## 例外 +`type1`または`type2`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_same_type(^^int, ^^int)); + static_assert(!std::meta::is_same_type(^^int, ^^double)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_same`](/reference/type_traits/is_same.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_scalar_type.md b/reference/meta/is_scalar_type.md new file mode 100644 index 0000000000..f5127345ed --- /dev/null +++ b/reference/meta/is_scalar_type.md @@ -0,0 +1,55 @@ +# is_scalar_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_scalar_type(info type); +} +``` +* info[link info.md] + +## 概要 +スカラ型であるかを判定する。 + + +## 戻り値 +`type`がスカラ型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_scalar_type(^^int)); + static_assert(!std::meta::is_scalar_type(^^std::string)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_scalar`](/reference/type_traits/is_scalar.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_scoped_enum_type.md b/reference/meta/is_scoped_enum_type.md new file mode 100644 index 0000000000..02333929b4 --- /dev/null +++ b/reference/meta/is_scoped_enum_type.md @@ -0,0 +1,59 @@ +# is_scoped_enum_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_scoped_enum_type(info type); +} +``` +* info[link info.md] + +## 概要 +スコープ付き列挙型であるかを判定する。 + + +## 戻り値 +`type`がスコープ付き列挙型(`enum class`)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +enum class ScopedEnum { a }; +enum UnscopedEnum { b }; + +int main() { + static_assert(std::meta::is_scoped_enum_type(^^ScopedEnum)); + static_assert(!std::meta::is_scoped_enum_type(^^UnscopedEnum)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_scoped_enum`](/reference/type_traits/is_scoped_enum.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_signed_type.md b/reference/meta/is_signed_type.md new file mode 100644 index 0000000000..8e6fd1a006 --- /dev/null +++ b/reference/meta/is_signed_type.md @@ -0,0 +1,55 @@ +# is_signed_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_signed_type(info type); +} +``` +* info[link info.md] + +## 概要 +符号付き型であるかを判定する。 + + +## 戻り値 +`type`が符号付き算術型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_signed_type(^^int)); + static_assert(!std::meta::is_signed_type(^^unsigned int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_signed`](/reference/type_traits/is_signed.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_special_member_function.md b/reference/meta/is_special_member_function.md new file mode 100644 index 0000000000..36df560e6c --- /dev/null +++ b/reference/meta/is_special_member_function.md @@ -0,0 +1,80 @@ +# is_special_member_function +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_special_member_function(info r); +} +``` +* info[link info.md] + +## 概要 +特殊メンバ関数であるかを判定する。 + + +## 戻り値 +`r`が特殊メンバ関数(デフォルトコンストラクタ、コピー/ムーブコンストラクタ、コピー/ムーブ代入演算子、デストラクタ)を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + S() = default; // 特殊メンバ関数 + S(const S&) = default; // 特殊メンバ関数 + S(S&&) = default; // 特殊メンバ関数 + S& operator=(const S&) = default; // 特殊メンバ関数 + S& operator=(S&&) = default; // 特殊メンバ関数 + ~S() = default; // 特殊メンバ関数 + S(int) {} // 特殊メンバ関数ではない + void f() {} // 特殊メンバ関数ではない +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_function(m)) { + std::println("{}: is_special_member_function={}", + std::meta::display_string_of(m), + std::meta::is_special_member_function(m)); + } + } +} +``` +* std::meta::is_special_member_function[color ff0000] +* std::meta::is_function[link is_function.md] +* std::meta::members_of[link members_of.md] +* std::meta::display_string_of[link display_string_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +S::S(): is_special_member_function=true +S::S(const S&): is_special_member_function=true +S::S(S&&): is_special_member_function=true +S::operator=(const S&): is_special_member_function=true +S::operator=(S&&): is_special_member_function=true +S::~S(): is_special_member_function=true +S::S(int): is_special_member_function=false +S::f(): is_special_member_function=false +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_standard_layout_type.md b/reference/meta/is_standard_layout_type.md new file mode 100644 index 0000000000..f2d64c113c --- /dev/null +++ b/reference/meta/is_standard_layout_type.md @@ -0,0 +1,55 @@ +# is_standard_layout_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_standard_layout_type(info type); +} +``` +* info[link info.md] + +## 概要 +スタンダードレイアウト型であるかを判定する。 + + +## 戻り値 +`type`がスタンダードレイアウト型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_standard_layout_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_standard_layout`](/reference/type_traits/is_standard_layout.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_static_member.md b/reference/meta/is_static_member.md new file mode 100644 index 0000000000..aff5de6c5b --- /dev/null +++ b/reference/meta/is_static_member.md @@ -0,0 +1,53 @@ +# is_static_member +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_static_member(info r); +} +``` +* info[link info.md] + +## 概要 +静的メンバであるかを判定する。 + + +## 戻り値 +`r`が静的メンバを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + int x; + static int y; +}; + +int main() { + static_assert(!std::meta::is_static_member(^^S::x)); + static_assert(std::meta::is_static_member(^^S::y)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_string_literal.md b/reference/meta/is_string_literal.md new file mode 100644 index 0000000000..c6feba76fa --- /dev/null +++ b/reference/meta/is_string_literal.md @@ -0,0 +1,84 @@ +# is_string_literal +* meta[meta header] +* std[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + consteval bool is_string_literal(const char* p); // (1) C++26 + consteval bool is_string_literal(const wchar_t* p); // (2) C++26 + consteval bool is_string_literal(const char8_t* p); // (3) C++26 + consteval bool is_string_literal(const char16_t* p); // (4) C++26 + consteval bool is_string_literal(const char32_t* p); // (5) C++26 +} +``` + +## 概要 +ポインタが文字列リテラル(またはそのサブオブジェクト)を指しているかどうかを判定する。 + +主に[`reflect_constant_string()`](reflect_constant_string.md)の内部実装で使用される。`reflect_constant_string()`は入力が既にヌル終端された文字列リテラルであればヌル終端文字を追加せず、そうでなければ追加する必要があるため、この関数で文字列リテラルかどうかを判定する。 + +ユーザーが直接使用する場合は、`const char*`の出自をコンパイル時に検査して、文字列リテラルに由来するポインタとそうでないポインタを区別する用途が考えられる。 + +- (1) : 通常の文字列リテラル(`"hello"`)を判定する +- (2) : ワイド文字列リテラル(`L"hello"`)を判定する +- (3) : UTF-8文字列リテラル(`u8"hello"`)を判定する +- (4) : UTF-16文字列リテラル(`u"hello"`)を判定する +- (5) : UTF-32文字列リテラル(`U"hello"`)を判定する + + +## 戻り値 +`p`が文字列リテラルまたはそのサブオブジェクトを指している場合に`true`を返す。そうでなければ`false`を返す。 + + +## 備考 +この関数は`std`名前空間に定義される(`std::meta`名前空間ではない)。 + + +## 例 +```cpp example +#include +#include + +// 文字列リテラルならそのまま使い、そうでなければコピーして使う +consteval const char* ensure_static(const char* p) { + if (std::is_string_literal(p)) { + return p; // 文字列リテラルは静的ストレージに既に存在する + } + return std::define_static_string(std::string_view(p)); +} + +int main() { + // 文字列リテラル + constexpr auto s1 = ensure_static("hello"); + std::println("{}", s1); + + // 文字列リテラルの部分文字列(サブオブジェクト) + static_assert(std::is_string_literal("hello" + 2)); // "llo"を指す +} +``` +* std::is_string_literal[color ff0000] +* std::define_static_string[link define_static_string.md] + +### 出力 +``` +hello +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_string`](define_static_string.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/is_structured_binding.md b/reference/meta/is_structured_binding.md new file mode 100644 index 0000000000..857967609c --- /dev/null +++ b/reference/meta/is_structured_binding.md @@ -0,0 +1,50 @@ +# is_structured_binding +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_structured_binding(info r); +} +``` +* info[link info.md] + +## 概要 +構造化束縛であるかを判定する。 + + +## 戻り値 +`r`が構造化束縛を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + auto [a, b] = std::pair{1, 2}; + static_assert(std::meta::is_structured_binding(^^a)); + static_assert(std::meta::is_structured_binding(^^b)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_swappable_type.md b/reference/meta/is_swappable_type.md new file mode 100644 index 0000000000..3570124f51 --- /dev/null +++ b/reference/meta/is_swappable_type.md @@ -0,0 +1,55 @@ +# is_swappable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_swappable_type(info type); +} +``` +* info[link info.md] + +## 概要 +swap可能型であるかを判定する。[`std::is_swappable`](/reference/type_traits/is_swappable.md)に対応する。 + + +## 戻り値 +`type`が表す型がswap可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_swappable_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_swappable`](/reference/type_traits/is_swappable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_swappable_with_type.md b/reference/meta/is_swappable_with_type.md new file mode 100644 index 0000000000..26f61d79a4 --- /dev/null +++ b/reference/meta/is_swappable_with_type.md @@ -0,0 +1,52 @@ +# is_swappable_with_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_swappable_with_type(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +指定した2つの型の間でswap可能かを判定する。[`std::is_swappable_with`](/reference/type_traits/is_swappable_with.md)に対応する。 + + +## 戻り値 +`type_dst`と`type_src`が表す型の間でswap可能な場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_swappable_with_type(^^int&, ^^int&)); +} +``` +* std::meta::is_swappable_with_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_template.md b/reference/meta/is_template.md new file mode 100644 index 0000000000..4cb143baec --- /dev/null +++ b/reference/meta/is_template.md @@ -0,0 +1,49 @@ +# is_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_template(info r); +} +``` +* info[link info.md] + +## 概要 +テンプレートであるかを判定する。 + + +## 戻り値 +`r`がテンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::is_template(^^std::vector)); + static_assert(!std::meta::is_template(^^std::vector)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_assignable_type.md b/reference/meta/is_trivially_assignable_type.md new file mode 100644 index 0000000000..e7ab7eeca4 --- /dev/null +++ b/reference/meta/is_trivially_assignable_type.md @@ -0,0 +1,63 @@ +# is_trivially_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_assignable_type(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +トリビアルに代入可能かを判定する。[`std::is_trivially_assignable`](/reference/type_traits/is_trivially_assignable.md)に対応する。 + + +## 戻り値 +`type_dst`と`type_src`が表す型について、トリビアルに代入可能な場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial& operator=(const int& v) { x = v; return *this; } + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_assignable_type(^^int&, ^^int)); + static_assert(std::meta::is_trivially_assignable_type(^^Trivial&, ^^Trivial)); + static_assert(!std::meta::is_trivially_assignable_type(^^NonTrivial&, ^^int)); +} +``` +* std::meta::is_trivially_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_constructible_type.md b/reference/meta/is_trivially_constructible_type.md new file mode 100644 index 0000000000..1233d13cfb --- /dev/null +++ b/reference/meta/is_trivially_constructible_type.md @@ -0,0 +1,67 @@ +# is_trivially_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval bool is_trivially_constructible_type(info type, R&& type_args); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +トリビアルに構築可能かを判定する。[`std::is_trivially_constructible`](/reference/type_traits/is_trivially_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型が`type_args`で指定された引数型でトリビアルに構築可能な場合に`true`を返す。 + + +## 例外 +`type`または`type_args`の各要素が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial(int v) : x(v) {} // ユーザー定義 + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_constructible_type(^^int, {^^int})); + static_assert(std::meta::is_trivially_constructible_type(^^Trivial, {^^Trivial})); + static_assert(!std::meta::is_trivially_constructible_type(^^NonTrivial, {^^int})); + static_assert(!std::meta::is_trivially_constructible_type(^^std::string, {^^const char*})); +} +``` +* std::meta::is_trivially_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_copy_assignable_type.md b/reference/meta/is_trivially_copy_assignable_type.md new file mode 100644 index 0000000000..7c4da73e2a --- /dev/null +++ b/reference/meta/is_trivially_copy_assignable_type.md @@ -0,0 +1,69 @@ +# is_trivially_copy_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_copy_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルにコピー代入可能型であるかを判定する。[`std::is_trivially_copy_assignable`](/reference/type_traits/is_trivially_copy_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルにコピー代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial& operator=(const NonTrivial& other) { x = other.x; return *this; } + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_copy_assignable_type(^^int)); + static_assert(std::meta::is_trivially_copy_assignable_type(^^Trivial)); + static_assert(!std::meta::is_trivially_copy_assignable_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_copy_assignable_type(^^std::string)); +} +``` +* std::meta::is_trivially_copy_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_copy_assignable`](/reference/type_traits/is_trivially_copy_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_copy_constructible_type.md b/reference/meta/is_trivially_copy_constructible_type.md new file mode 100644 index 0000000000..7c6bd6c5fb --- /dev/null +++ b/reference/meta/is_trivially_copy_constructible_type.md @@ -0,0 +1,69 @@ +# is_trivially_copy_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_copy_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルにコピー構築可能型であるかを判定する。[`std::is_trivially_copy_constructible`](/reference/type_traits/is_trivially_copy_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルにコピー構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial(const NonTrivial& other) : x(other.x) {} // ユーザー定義 + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_copy_constructible_type(^^int)); + static_assert(std::meta::is_trivially_copy_constructible_type(^^Trivial)); + static_assert(!std::meta::is_trivially_copy_constructible_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_copy_constructible_type(^^std::string)); +} +``` +* std::meta::is_trivially_copy_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_copy_constructible`](/reference/type_traits/is_trivially_copy_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_copyable_type.md b/reference/meta/is_trivially_copyable_type.md new file mode 100644 index 0000000000..685cc86963 --- /dev/null +++ b/reference/meta/is_trivially_copyable_type.md @@ -0,0 +1,69 @@ +# is_trivially_copyable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_copyable_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルコピー可能型であるかを判定する。 + + +## 戻り値 +`type`がトリビアルコピー可能型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; + double y; +}; + +struct NonTrivial { + NonTrivial(const NonTrivial&) {} // ユーザー定義コピーコンストラクタ +}; + +int main() { + static_assert(std::meta::is_trivially_copyable_type(^^int)); + static_assert(std::meta::is_trivially_copyable_type(^^Trivial)); + static_assert(!std::meta::is_trivially_copyable_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_copyable_type(^^std::string)); +} +``` +* std::meta::is_trivially_copyable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_copyable`](/reference/type_traits/is_trivially_copyable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_default_constructible_type.md b/reference/meta/is_trivially_default_constructible_type.md new file mode 100644 index 0000000000..17f0ff1cce --- /dev/null +++ b/reference/meta/is_trivially_default_constructible_type.md @@ -0,0 +1,67 @@ +# is_trivially_default_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_default_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルにデフォルト構築可能型であるかを判定する。[`std::is_trivially_default_constructible`](/reference/type_traits/is_trivially_default_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルにデフォルト構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial() : x(42) {} // ユーザー定義 + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_default_constructible_type(^^int)); + static_assert(std::meta::is_trivially_default_constructible_type(^^Trivial)); + static_assert(!std::meta::is_trivially_default_constructible_type(^^NonTrivial)); +} +``` +* std::meta::is_trivially_default_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_default_constructible`](/reference/type_traits/is_trivially_default_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_destructible_type.md b/reference/meta/is_trivially_destructible_type.md new file mode 100644 index 0000000000..a82d82c90e --- /dev/null +++ b/reference/meta/is_trivially_destructible_type.md @@ -0,0 +1,68 @@ +# is_trivially_destructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_destructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルに破棄可能型であるかを判定する。[`std::is_trivially_destructible`](/reference/type_traits/is_trivially_destructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルに破棄可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + ~NonTrivial() { /* ユーザー定義デストラクタ */ } +}; + +int main() { + static_assert(std::meta::is_trivially_destructible_type(^^int)); + static_assert(std::meta::is_trivially_destructible_type(^^Trivial)); + static_assert(!std::meta::is_trivially_destructible_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_destructible_type(^^std::unique_ptr)); +} +``` +* std::meta::is_trivially_destructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_destructible`](/reference/type_traits/is_trivially_destructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_move_assignable_type.md b/reference/meta/is_trivially_move_assignable_type.md new file mode 100644 index 0000000000..cbcc530d98 --- /dev/null +++ b/reference/meta/is_trivially_move_assignable_type.md @@ -0,0 +1,69 @@ +# is_trivially_move_assignable_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_move_assignable_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルにムーブ代入可能型であるかを判定する。[`std::is_trivially_move_assignable`](/reference/type_traits/is_trivially_move_assignable.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルにムーブ代入可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial& operator=(NonTrivial&& other) { x = other.x; return *this; } + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_move_assignable_type(^^int)); + static_assert(std::meta::is_trivially_move_assignable_type(^^Trivial)); + static_assert(!std::meta::is_trivially_move_assignable_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_move_assignable_type(^^std::unique_ptr)); +} +``` +* std::meta::is_trivially_move_assignable_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_move_assignable`](/reference/type_traits/is_trivially_move_assignable.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_trivially_move_constructible_type.md b/reference/meta/is_trivially_move_constructible_type.md new file mode 100644 index 0000000000..d25b4d0a94 --- /dev/null +++ b/reference/meta/is_trivially_move_constructible_type.md @@ -0,0 +1,69 @@ +# is_trivially_move_constructible_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_trivially_move_constructible_type(info type); +} +``` +* info[link info.md] + +## 概要 +トリビアルにムーブ構築可能型であるかを判定する。[`std::is_trivially_move_constructible`](/reference/type_traits/is_trivially_move_constructible.md)に対応する。 + + +## 戻り値 +`type`が表す型がトリビアルにムーブ構築可能型である場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Trivial { + int x; +}; + +struct NonTrivial { + NonTrivial(NonTrivial&& other) : x(other.x) {} // ユーザー定義 + int x; +}; + +int main() { + static_assert(std::meta::is_trivially_move_constructible_type(^^int)); + static_assert(std::meta::is_trivially_move_constructible_type(^^Trivial)); + static_assert(!std::meta::is_trivially_move_constructible_type(^^NonTrivial)); + static_assert(!std::meta::is_trivially_move_constructible_type(^^std::unique_ptr)); +} +``` +* std::meta::is_trivially_move_constructible_type[color ff0000] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_trivially_move_constructible`](/reference/type_traits/is_trivially_move_constructible.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_type.md b/reference/meta/is_type.md new file mode 100644 index 0000000000..a807c51d9a --- /dev/null +++ b/reference/meta/is_type.md @@ -0,0 +1,49 @@ +# is_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_type(info r); +} +``` +* info[link info.md] + +## 概要 +型であるかを判定する。 + + +## 戻り値 +`r`が型を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_type(^^int)); + static_assert(std::meta::is_type(^^std::string)); + static_assert(!std::meta::is_type(^^std)); // 名前空間は型ではない +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_type_alias.md b/reference/meta/is_type_alias.md new file mode 100644 index 0000000000..d9f54631e9 --- /dev/null +++ b/reference/meta/is_type_alias.md @@ -0,0 +1,52 @@ +# is_type_alias +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_type_alias(info r); +} +``` +* info[link info.md] + +## 概要 +型エイリアスであるかを判定する。 + + +## 戻り値 +`r`が型エイリアス(`using`宣言や`typedef`)を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +using MyInt = int; +typedef double MyDouble; + +int main() { + static_assert(std::meta::is_type_alias(^^MyInt)); + static_assert(std::meta::is_type_alias(^^MyDouble)); + static_assert(!std::meta::is_type_alias(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_unbounded_array_type.md b/reference/meta/is_unbounded_array_type.md new file mode 100644 index 0000000000..0dc2a8f34a --- /dev/null +++ b/reference/meta/is_unbounded_array_type.md @@ -0,0 +1,55 @@ +# is_unbounded_array_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_unbounded_array_type(info type); +} +``` +* info[link info.md] + +## 概要 +境界なし配列型であるかを判定する。 + + +## 戻り値 +`type`が境界なし配列型(`T[]`)を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_unbounded_array_type(^^int[])); + static_assert(!std::meta::is_unbounded_array_type(^^int[3])); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_unbounded_array`](/reference/type_traits/is_unbounded_array.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_union_type.md b/reference/meta/is_union_type.md new file mode 100644 index 0000000000..b34fccab3f --- /dev/null +++ b/reference/meta/is_union_type.md @@ -0,0 +1,59 @@ +# is_union_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_union_type(info type); +} +``` +* info[link info.md] + +## 概要 +共用体型であるかを判定する。 + + +## 戻り値 +`type`が共用体型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +union U {{ int i; double d; }}; +struct S {{ int x; }}; + +int main() { + static_assert(std::meta::is_union_type(^^U)); + static_assert(!std::meta::is_union_type(^^S)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_union`](/reference/type_traits/is_union.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_unsigned_type.md b/reference/meta/is_unsigned_type.md new file mode 100644 index 0000000000..3d5c6a186f --- /dev/null +++ b/reference/meta/is_unsigned_type.md @@ -0,0 +1,55 @@ +# is_unsigned_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_unsigned_type(info type); +} +``` +* info[link info.md] + +## 概要 +符号なし型であるかを判定する。 + + +## 戻り値 +`type`が符号なし算術型を表す場合に`true`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +int main() { + static_assert(std::meta::is_unsigned_type(^^unsigned int)); + static_assert(!std::meta::is_unsigned_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_unsigned`](/reference/type_traits/is_unsigned.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_user_declared.md b/reference/meta/is_user_declared.md new file mode 100644 index 0000000000..cdca2e5ce3 --- /dev/null +++ b/reference/meta/is_user_declared.md @@ -0,0 +1,63 @@ +# is_user_declared +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_user_declared(info r); +} +``` +* info[link info.md] + +## 概要 +ユーザー宣言であるかを判定する。 + + +## 戻り値 +`r`がユーザー宣言された関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; // ユーザー宣言だがユーザー提供ではない + void f() {} // ユーザー提供 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_default_constructor(m)) { + static_assert(std::meta::is_user_declared(m)); + static_assert(!std::meta::is_user_provided(m)); + } + } +} +``` +* std::meta::is_default_constructor[link is_default_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::is_user_provided[link is_user_provided.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_user_provided.md b/reference/meta/is_user_provided.md new file mode 100644 index 0000000000..d2e715b6b9 --- /dev/null +++ b/reference/meta/is_user_provided.md @@ -0,0 +1,63 @@ +# is_user_provided +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_user_provided(info r); +} +``` +* info[link info.md] + +## 概要 +ユーザー提供であるかを判定する。 + + +## 戻り値 +`r`がユーザー提供の関数を表す場合に`true`を返す。ユーザー提供とは、ユーザーが宣言し、かつ最初の宣言で`= default`も`= delete`もされていないことを意味する。 + + +## 例 +```cpp example +#include + +struct S { + S() = default; // ユーザー宣言だがユーザー提供ではない + void f() {} // ユーザー提供 +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_default_constructor(m)) { + static_assert(std::meta::is_user_declared(m)); + static_assert(!std::meta::is_user_provided(m)); + } + } +} +``` +* std::meta::is_default_constructor[link is_default_constructor.md] +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::is_user_declared[link is_user_declared.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_value.md b/reference/meta/is_value.md new file mode 100644 index 0000000000..4e2ef67b89 --- /dev/null +++ b/reference/meta/is_value.md @@ -0,0 +1,48 @@ +# is_value +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_value(info r); +} +``` +* info[link info.md] + +## 概要 +値であるかを判定する。 + + +## 戻り値 +`r`が値を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int main() { + constexpr auto r = std::meta::reflect_constant(42); + static_assert(std::meta::is_value(r)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_variable.md b/reference/meta/is_variable.md new file mode 100644 index 0000000000..d29d51a7ba --- /dev/null +++ b/reference/meta/is_variable.md @@ -0,0 +1,50 @@ +# is_variable +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_variable(info r); +} +``` +* info[link info.md] + +## 概要 +変数であるかを判定する。 + + +## 戻り値 +`r`が変数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +int global_var = 0; + +int main() { + static_assert(std::meta::is_variable(^^global_var)); + static_assert(!std::meta::is_variable(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_variable_template.md b/reference/meta/is_variable_template.md new file mode 100644 index 0000000000..674fed1fc4 --- /dev/null +++ b/reference/meta/is_variable_template.md @@ -0,0 +1,48 @@ +# is_variable_template +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_variable_template(info r); +} +``` +* info[link info.md] + +## 概要 +変数テンプレートであるかを判定する。 + + +## 戻り値 +`r`が変数テンプレートを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::is_variable_template(^^std::is_integral_v)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_virtual.md b/reference/meta/is_virtual.md new file mode 100644 index 0000000000..18de3d0b90 --- /dev/null +++ b/reference/meta/is_virtual.md @@ -0,0 +1,53 @@ +# is_virtual +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_virtual(info r); +} +``` +* info[link info.md] + +## 概要 +`virtual`であるかを判定する。 + + +## 戻り値 +`r`が`virtual`指定されたメンバ関数または基底クラスを表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct Base { + virtual void f() {} + void g() {} +}; + +int main() { + static_assert(std::meta::is_virtual(^^Base::f)); + static_assert(!std::meta::is_virtual(^^Base::g)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_virtual_base_of_type.md b/reference/meta/is_virtual_base_of_type.md new file mode 100644 index 0000000000..58c698a175 --- /dev/null +++ b/reference/meta/is_virtual_base_of_type.md @@ -0,0 +1,56 @@ +# is_virtual_base_of_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_virtual_base_of_type(info type_base, info type_derived); +} +``` +* info[link info.md] + +## 概要 +型が別の型の仮想基底クラスであるかを判定する。 + + +## 戻り値 +`type_base`が`type_derived`の仮想基底クラスである場合に`true`を返す。 + + +## 例外 +`type_base`または`type_derived`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +struct Base {}; +struct Derived : virtual Base {}; +struct NonVirtual : Base {}; + +int main() { + static_assert(std::meta::is_virtual_base_of_type(^^Base, ^^Derived)); + static_assert(!std::meta::is_virtual_base_of_type(^^Base, ^^NonVirtual)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_void_type.md b/reference/meta/is_void_type.md new file mode 100644 index 0000000000..4c1dac2e51 --- /dev/null +++ b/reference/meta/is_void_type.md @@ -0,0 +1,56 @@ +# is_void_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_void_type(info type); +} +``` +* info[link info.md] + +## 概要 +`void`型(CV修飾を含む)であるかを判定する。 + + +## 戻り値 +`type`が`void`型(CV修飾を含む)を表す場合に`true`を返す。 + + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_void_type(^^void)); + static_assert(!std::meta::is_void_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_void`](/reference/type_traits/is_void.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_volatile.md b/reference/meta/is_volatile.md new file mode 100644 index 0000000000..fb7f626a9d --- /dev/null +++ b/reference/meta/is_volatile.md @@ -0,0 +1,53 @@ +# is_volatile +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_volatile(info r); +} +``` +* info[link info.md] + +## 概要 +`volatile`修飾されているかを判定する。 + + +## 戻り値 +`r`が`volatile`修飾されたメンバ関数を表す場合に`true`を返す。 + + +## 例 +```cpp example +#include + +struct S { + void f() {} + void g() volatile {} +}; + +int main() { + static_assert(!std::meta::is_volatile(^^S::f)); + static_assert(std::meta::is_volatile(^^S::g)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/is_volatile_type.md b/reference/meta/is_volatile_type.md new file mode 100644 index 0000000000..811bdc8e20 --- /dev/null +++ b/reference/meta/is_volatile_type.md @@ -0,0 +1,56 @@ +# is_volatile_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool is_volatile_type(info type); +} +``` +* info[link info.md] + +## 概要 +`volatile`修飾された型であるかを判定する。 + + +## 戻り値 +`type`が最上位で`volatile`修飾された型を表す場合に`true`を返す。 + + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::is_volatile_type(^^volatile int)); + static_assert(!std::meta::is_volatile_type(^^int)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::is_volatile`](/reference/type_traits/is_volatile.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/make_signed.md b/reference/meta/make_signed.md new file mode 100644 index 0000000000..4d84b661dd --- /dev/null +++ b/reference/meta/make_signed.md @@ -0,0 +1,55 @@ +# make_signed +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info make_signed(info type); +} +``` +* info[link info.md] + +## 概要 +型を対応する符号付き整数型に変換する。[`std::make_signed`](/reference/type_traits/make_signed.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::make_signed`](/reference/type_traits/make_signed.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::make_signed(^^unsigned int) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::make_signed`](/reference/type_traits/make_signed.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/make_unsigned.md b/reference/meta/make_unsigned.md new file mode 100644 index 0000000000..e16f6033f0 --- /dev/null +++ b/reference/meta/make_unsigned.md @@ -0,0 +1,55 @@ +# make_unsigned +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info make_unsigned(info type); +} +``` +* info[link info.md] + +## 概要 +型を対応する符号なし整数型に変換する。[`std::make_unsigned`](/reference/type_traits/make_unsigned.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::make_unsigned`](/reference/type_traits/make_unsigned.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::make_unsigned(^^int) == ^^unsigned int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::make_unsigned`](/reference/type_traits/make_unsigned.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/member_offset.md b/reference/meta/member_offset.md new file mode 100644 index 0000000000..fb04817ec1 --- /dev/null +++ b/reference/meta/member_offset.md @@ -0,0 +1,51 @@ +# member_offset +* meta[meta header] +* std::meta[meta namespace] +* class[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + struct member_offset { + ptrdiff_t bytes; + ptrdiff_t bits; + constexpr ptrdiff_t total_bits() const; + auto operator<=>(const member_offset&) const = default; + }; +} +``` + +## 概要 +`member_offset`は、非静的データメンバのオフセットを表すクラスである。[`offset_of()`](offset_of.md)の戻り値型として使用される。 + +## メンバ変数 + +| 名前 | 説明 | +|------|------| +| `bytes` | バイト単位のオフセット | +| `bits` | ビット単位の追加オフセット | + +## メンバ関数 + +| 名前 | 説明 | +|------|------| +| `total_bits()` | `bytes * CHAR_BIT + bits`を返す | +| `operator<=>` | 三方比較(デフォルト) | + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`offset_of`](offset_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/members_of.md b/reference/meta/members_of.md new file mode 100644 index 0000000000..359c404fed --- /dev/null +++ b/reference/meta/members_of.md @@ -0,0 +1,70 @@ +# members_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector members_of(info r, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスまたは名前空間のすべてのメンバのリフレクションを取得する。 + + +## 戻り値 +`r`が完全型のクラスまたは名前空間を表す場合、アクセスコンテキスト`ctx`でアクセス可能なすべてのメンバのリフレクションを格納した`vector`を返す。 + + +## 例外 +`r`が完全型のクラスまたは名前空間を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct S { + int x; + double y; + void f() {} +}; + +int main() { + constexpr auto members = std::meta::members_of( + ^^S, std::meta::access_context::unchecked()); + std::println("メンバ数: {}", members.size()); +} +``` +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`nonstatic_data_members_of`](nonstatic_data_members_of.md) +- [`static_data_members_of`](static_data_members_of.md) +- [`bases_of`](bases_of.md) +- [`access_context`](access_context.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/nonstatic_data_members_of.md b/reference/meta/nonstatic_data_members_of.md new file mode 100644 index 0000000000..204e12509c --- /dev/null +++ b/reference/meta/nonstatic_data_members_of.md @@ -0,0 +1,73 @@ +# nonstatic_data_members_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector nonstatic_data_members_of(info type, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスの非静的データメンバのリフレクションを取得する。 + + +## 戻り値 +`type`が完全型のクラスを表す場合、アクセスコンテキスト`ctx`でアクセス可能な非静的データメンバのリフレクションを宣言順に格納した`vector`を返す。 + + +## 例外 +`r`が完全型のクラスを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Point { + int x; + int y; +}; + +int main() { + Point p{10, 20}; + template for (constexpr auto m : + std::meta::nonstatic_data_members_of(^^Point, + std::meta::access_context::unchecked())) { + std::println("{} = {}", std::meta::identifier_of(m), p.[:m:]); + } +} +``` +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::identifier_of[link identifier_of.md] + +### 出力 +``` +x = 10 +y = 20 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`members_of`](members_of.md) +- [`subobjects_of`](subobjects_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/object_of.md b/reference/meta/object_of.md new file mode 100644 index 0000000000..64eb3c977f --- /dev/null +++ b/reference/meta/object_of.md @@ -0,0 +1,55 @@ +# object_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info object_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションが表す変数のオブジェクトのリフレクションを取得する。 + + +## 戻り値 +`r`が変数または構造化束縛を表す場合、そのオブジェクトのリフレクションを返す。 + + +## 例外 +`r`が静的記憶域期間を持つオブジェクト、またはそのようなオブジェクトを宣言・参照する変数を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +static int global_var = 42; + +int main() { + constexpr auto obj = std::meta::object_of(^^global_var); + static_assert(std::meta::is_object(obj)); +} +``` +* std::meta::is_object[link is_object.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/offset_of.md b/reference/meta/offset_of.md new file mode 100644 index 0000000000..a42c2130a9 --- /dev/null +++ b/reference/meta/offset_of.md @@ -0,0 +1,84 @@ +# offset_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval member_offset offset_of(info r); +} +``` +* info[link info.md] + +## 概要 +非静的データメンバのオフセットを取得する。 + + +## 戻り値 +`r`が非静的データメンバを表す場合、そのメンバの所属するクラスの先頭からのオフセットを[`member_offset`](member_offset.md)として返す。 + + +## 例外 +`r`が非静的データメンバまたは基底クラス関係を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct S { + char a; + int b; + double c; +}; + +int main() { + std::println("sizeof(S) = {}", sizeof(S)); + + template for (constexpr auto m : + std::meta::nonstatic_data_members_of( + ^^S, std::meta::access_context::unchecked())) { + constexpr auto off = std::meta::offset_of(m); + std::println("{}: offset = {} bytes, size = {}", + std::meta::identifier_of(m), + off.bytes, + std::meta::size_of(m)); + } +} +``` +* std::meta::offset_of[color ff0000] +* std::meta::nonstatic_data_members_of[link nonstatic_data_members_of.md] +* std::meta::identifier_of[link identifier_of.md] +* std::meta::size_of[link size_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] + +#### 出力例 +``` +sizeof(S) = 16 +a: offset = 0 bytes, size = 1 +b: offset = 4 bytes, size = 4 +c: offset = 8 bytes, size = 8 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`member_offset`](member_offset.md) +- [`size_of`](size_of.md) +- [`alignment_of`](alignment_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/operator_of.md b/reference/meta/operator_of.md new file mode 100644 index 0000000000..d4a406cbb6 --- /dev/null +++ b/reference/meta/operator_of.md @@ -0,0 +1,68 @@ +# operator_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval operators operator_of(info r); +} +``` +* info[link info.md] +* operators[link operators.md] + +## 概要 +演算子のリフレクションから演算子の種類を取得する。 + + +## 戻り値 +`r`が演算子関数またはリテラル演算子を表すリフレクションである場合、対応する[`operators`](operators.md)列挙値を返す。 + + +## 例外 +`r`が演算子関数または演算子関数テンプレートを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct S { + bool operator==(const S&) const = default; +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_operator_function(m)) { + std::println("演算子: {}", std::meta::symbol_of(std::meta::operator_of(m))); + } + } +} +``` +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::is_operator_function[link is_operator_function.md] +* std::meta::symbol_of[link symbol_of.md] + +### 出力 +``` +演算子: == +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/operators.md b/reference/meta/operators.md new file mode 100644 index 0000000000..93c15dfade --- /dev/null +++ b/reference/meta/operators.md @@ -0,0 +1,85 @@ +# operators +* meta[meta header] +* std::meta[meta namespace] +* enum[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + enum class operators; +} +``` + +## 概要 +`operators`は、C++のオーバーロード可能な演算子の種類を表すスコープ付き列挙型である。[`operator_of()`](operator_of.md)の戻り値型として使用される。 + +各列挙子は`std::meta`名前空間でも直接使用できる(`using enum operators;`が適用されている)。 + + +## 列挙子 + +| 列挙子 | 対応する演算子 | +|--------|---------------| +| `op_new` | `operator new` | +| `op_delete` | `operator delete` | +| `op_array_new` | `operator new[]` | +| `op_array_delete` | `operator delete[]` | +| `op_co_await` | `operator co_await` | +| `op_parentheses` | `operator()` | +| `op_square_brackets` | `operator[]` | +| `op_arrow` | `operator->` | +| `op_arrow_star` | `operator->*` | +| `op_tilde` | `operator~` | +| `op_exclamation` | `operator!` | +| `op_plus` | `operator+` | +| `op_minus` | `operator-` | +| `op_star` | `operator*` | +| `op_slash` | `operator/` | +| `op_percent` | `operator%` | +| `op_caret` | `operator^` | +| `op_ampersand` | `operator&` | +| `op_pipe` | operator| | +| `op_equals` | `operator=` | +| `op_plus_equals` | `operator+=` | +| `op_minus_equals` | `operator-=` | +| `op_star_equals` | `operator*=` | +| `op_slash_equals` | `operator/=` | +| `op_percent_equals` | `operator%=` | +| `op_caret_equals` | `operator^=` | +| `op_ampersand_equals` | `operator&=` | +| `op_pipe_equals` | operator|= | +| `op_equals_equals` | `operator==` | +| `op_exclamation_equals` | `operator!=` | +| `op_less` | `operator<` | +| `op_greater` | `operator>` | +| `op_less_equals` | `operator<=` | +| `op_greater_equals` | `operator>=` | +| `op_spaceship` | `operator<=>` | +| `op_ampersand_ampersand` | `operator&&` | +| `op_pipe_pipe` | operator|| | +| `op_less_less` | `operator<<` | +| `op_greater_greater` | `operator>>` | +| `op_less_less_equals` | `operator<<=` | +| `op_greater_greater_equals` | `operator>>=` | +| `op_plus_plus` | `operator++` | +| `op_minus_minus` | `operator--` | +| `op_comma` | `operator,` | + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`operator_of`](operator_of.md) +- [`symbol_of`](symbol_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/parameters_of.md b/reference/meta/parameters_of.md new file mode 100644 index 0000000000..ecae234e24 --- /dev/null +++ b/reference/meta/parameters_of.md @@ -0,0 +1,71 @@ +# parameters_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector parameters_of(info r); +} +``` +* info[link info.md] + +## 概要 +関数の仮引数のリフレクションを取得する。 + + +## 戻り値 +`r`が関数を表す場合、その仮引数のリフレクションを宣言順に格納した`std::vector`オブジェクトを返す。`r`が関数型を表す場合、パラメータ型リスト中の型のリフレクションを返す。 + + +## 例外 +`r`が関数または関数型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +void process(int id, double value, const char* name) {} + +int main() { + template for (constexpr auto p : std::meta::parameters_of(^^process)) { + std::println("{}: {}", + std::meta::identifier_of(p), + std::meta::display_string_of(std::meta::type_of(p))); + } +} +``` +* std::meta::identifier_of[link identifier_of.md] +* std::meta::type_of[link type_of.md] +* std::meta::display_string_of[link display_string_of.md] + +### 出力 +``` +id: int +value: double +name: const char* +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`return_type_of`](return_type_of.md) +- [`variable_of`](variable_of.md) +- [`has_default_argument`](has_default_argument.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/parent_of.md b/reference/meta/parent_of.md new file mode 100644 index 0000000000..14dd553f4e --- /dev/null +++ b/reference/meta/parent_of.md @@ -0,0 +1,56 @@ +# parent_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info parent_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションの親スコープのリフレクションを取得する。 + + +## 戻り値 +`r`が属するスコープのリフレクションを返す。[`has_parent`](has_parent.md)`(r)`が`true`であることが事前条件となる。 + + +## 例外 +[`has_parent`](has_parent.md)`(r)`が`false`の場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +namespace ns { + struct S {}; +} + +int main() { + static_assert(std::meta::has_parent(^^ns::S)); + static_assert(std::meta::parent_of(^^ns::S) == ^^ns); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/rank.md b/reference/meta/rank.md new file mode 100644 index 0000000000..23ee91ea3b --- /dev/null +++ b/reference/meta/rank.md @@ -0,0 +1,58 @@ +# rank +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval size_t rank(info type); +} +``` +* info[link info.md] + +## 概要 +配列型の次元数を取得する。[`std::rank`](/reference/type_traits/rank.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::rank`](/reference/type_traits/rank.md)相当の値を返す。配列型でなければ`0`を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::rank(^^int[3][4]) == 2); + static_assert(std::meta::rank(^^int[3]) == 1); + static_assert(std::meta::rank(^^int) == 0); +} +``` +* std::meta::rank[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`extent`](extent.md) +- [`std::rank`](/reference/type_traits/rank.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reference_constructs_from_temporary.md b/reference/meta/reference_constructs_from_temporary.md new file mode 100644 index 0000000000..2d594131da --- /dev/null +++ b/reference/meta/reference_constructs_from_temporary.md @@ -0,0 +1,57 @@ +# reference_constructs_from_temporary +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool reference_constructs_from_temporary(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +参照が一時オブジェクトから構築されるかを判定する。[`std::reference_constructs_from_temporary`](/reference/type_traits/reference_constructs_from_temporary.md)に対応する。 + + +## 戻り値 +`type_dst`の参照が`type_src`からの一時オブジェクトに束縛される場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::reference_constructs_from_temporary( + ^^const std::string&, ^^const char*)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::reference_constructs_from_temporary`](/reference/type_traits/reference_constructs_from_temporary.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reference_converts_from_temporary.md b/reference/meta/reference_converts_from_temporary.md new file mode 100644 index 0000000000..674c1de3c2 --- /dev/null +++ b/reference/meta/reference_converts_from_temporary.md @@ -0,0 +1,57 @@ +# reference_converts_from_temporary +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval bool reference_converts_from_temporary(info type_dst, info type_src); +} +``` +* info[link info.md] + +## 概要 +参照への変換が一時オブジェクトを経由するかを判定する。[`std::reference_converts_from_temporary`](/reference/type_traits/reference_converts_from_temporary.md)に対応する。 + + +## 戻り値 +`type_dst`の参照が`type_src`からの暗黙変換で一時オブジェクトに束縛される場合に`true`を返す。 + + +## 例外 +`type_dst`または`type_src`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::reference_converts_from_temporary( + ^^const std::string&, ^^const char*)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::reference_converts_from_temporary`](/reference/type_traits/reference_converts_from_temporary.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reflect_constant.md b/reference/meta/reflect_constant.md new file mode 100644 index 0000000000..a7225da309 --- /dev/null +++ b/reference/meta/reflect_constant.md @@ -0,0 +1,60 @@ +# reflect_constant +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval info reflect_constant(const T& value); +} +``` +* info[link info.md] + +## 概要 +値からリフレクションを生成する。 + + +## 戻り値 +`value`の値を表すリフレクションを返す。 + + +## 例 +```cpp example +#include + +enum class Color { red = 1, green = 2, blue = 3 }; + +int main() { + constexpr auto r = std::meta::reflect_constant(42); + static_assert(std::meta::extract(r) == 42); + + constexpr auto c = std::meta::reflect_constant(Color::green); + static_assert(std::meta::extract(c) == Color::green); +} +``` +* std::meta::extract[link extract.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`extract`](extract.md) +- [`reflect_object`](reflect_object.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reflect_constant_array.md b/reference/meta/reflect_constant_array.md new file mode 100644 index 0000000000..c052734837 --- /dev/null +++ b/reference/meta/reflect_constant_array.md @@ -0,0 +1,65 @@ +# reflect_constant_array +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval info reflect_constant_array(R&& r); +} +``` +* info[link info.md] + +## 概要 +構造的型の要素を持つRangeから、静的配列のリフレクションを生成する。 + +[`define_static_array()`](define_static_array.md)は[`span`](/reference/span/span.md)を返すため実行時のアクセスには便利だが、`span`は構造化束縛によるパック展開ができない。この関数は配列のリフレクションを返すため、スプライスして構造化束縛でパック展開する用途に使用できる。 + +また、[`define_static_array()`](define_static_array.md)はこの関数を内部で使用して実装されている。 + + +## 戻り値 +`r`の要素をコピーした`const T[N]`のテンプレートパラメータオブジェクトのリフレクションを返す。 + + +## 例 +```cpp example +#include +#include + +consteval int sum() { + // 配列のリフレクションをスプライスし、構造化束縛でパック展開 + constexpr auto [...elems] = + [:std::meta::reflect_constant_array(std::array{1, 2, 3}):]; + return (... + elems); +} + +int main() { + static_assert(sum() == 6); +} +``` +* std::meta::reflect_constant_array[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_array`](define_static_array.md) +- [`reflect_constant_string`](reflect_constant_string.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/reflect_constant_string.md b/reference/meta/reflect_constant_string.md new file mode 100644 index 0000000000..6fe3824518 --- /dev/null +++ b/reference/meta/reflect_constant_string.md @@ -0,0 +1,74 @@ +# reflect_constant_string +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval info reflect_constant_string(R&& r); +} +``` +* info[link info.md] + +## 概要 +文字のRangeからヌル終端文字配列のリフレクションを生成する。 + +[`define_static_string()`](define_static_string.md)は`const CharT*`を返すため配列のサイズ情報が失われるが、この関数はサイズ情報を保持した配列のリフレクションを返す。そのため、サイズをテンプレートパラメータとして推論する必要がある型(`FixedString`など)にスプライスで渡すことができる。 + +また、[`define_static_string()`](define_static_string.md)はこの関数を内部で使用して実装されている。 + + +## 戻り値 +`r`の要素をコピーしたヌル終端文字配列`const CharT[sizeof...(V)+1]`のテンプレートパラメータオブジェクトのリフレクションを返す。 + + +## 例 +```cpp example +#include +#include +#include + +template +struct FixedString { + char data[N] = {}; + constexpr FixedString(const char (&str)[N]) { + std::ranges::copy(str, str + N, data); + } +}; + +template +struct Named {}; + +int main() { + // define_static_stringはconst char*を返すためFixedStringのサイズを推論できない + // using Err = Named; // エラー + + // reflect_constant_stringはサイズ付き配列のリフレクションを返すため推論できる + using Ok = Named<[:std::meta::reflect_constant_string("hello"):]>; +} +``` +* std::meta::reflect_constant_string[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`define_static_string`](define_static_string.md) +- [`reflect_constant_array`](reflect_constant_array.md) + + +## 参照 +- [P3491R3 `define_static_{string,object,array}`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r3.html) diff --git a/reference/meta/reflect_function.md b/reference/meta/reflect_function.md new file mode 100644 index 0000000000..319918076e --- /dev/null +++ b/reference/meta/reflect_function.md @@ -0,0 +1,57 @@ +# reflect_function +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval info reflect_function(T& fn); +} +``` +* info[link info.md] + +## 概要 +関数からリフレクションを生成する。 + + +## 戻り値 +関数`fn`を表すリフレクションを返す。 + + +## 例 +```cpp example +#include + +void my_func() {} + +int main() { + constexpr auto r = std::meta::reflect_function(my_func); + static_assert(std::meta::is_function(r)); +} +``` +* std::meta::is_function[link is_function.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`reflect_object`](reflect_object.md) +- [`reflect_constant`](reflect_constant.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reflect_object.md b/reference/meta/reflect_object.md new file mode 100644 index 0000000000..a7c119a25e --- /dev/null +++ b/reference/meta/reflect_object.md @@ -0,0 +1,56 @@ +# reflect_object +* meta[meta header] +* std::meta[meta namespace] +* function template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + consteval info reflect_object(T& object); +} +``` +* info[link info.md] + +## 概要 +オブジェクトからリフレクションを生成する。 + + +## 戻り値 +`object`を表すリフレクションを返す。 + + +## 例 +```cpp example +#include + +static constexpr int value = 100; + +int main() { + constexpr auto r = std::meta::reflect_object(value); + static_assert(std::meta::is_object(r)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`reflect_constant`](reflect_constant.md) +- [`reflect_function`](reflect_function.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/reflection_range.md b/reference/meta/reflection_range.md new file mode 100644 index 0000000000..071d91655d --- /dev/null +++ b/reference/meta/reflection_range.md @@ -0,0 +1,62 @@ +# reflection_range +* meta[meta header] +* std::meta[meta namespace] +* concept[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template + concept reflection_range = ranges::input_range && + same_as, info>; +} +``` +* info[link info.md] + +## 概要 +`reflection_range`は、要素型が[`std::meta::info`](info.md)であるRangeを表すコンセプトである。 + +[`substitute()`](substitute.md)、[`define_aggregate()`](define_aggregate.md)、[`common_type()`](common_type.md)など、複数のリフレクションをまとめて受け取るメタ関数のテンプレートパラメータ制約として使用される。デフォルトのテンプレート引数は[`std::initializer_list`](/reference/initializer_list/initializer_list.md)``であり、ブレース初期化子リスト`{^^int, ^^double}`のような形式でリフレクションを渡すことができる。 + + +## 例 +```cpp example +#include +#include + +int main() { + // initializer_listで渡す(デフォルト) + constexpr auto r1 = std::meta::substitute(^^std::vector, {^^int}); + + // vectorで渡す + constexpr std::vector args = {^^int}; + constexpr auto r2 = std::meta::substitute(^^std::vector, args); + + static_assert(r1 == r2); +} +``` +* std::meta::substitute[link substitute.md] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`info`](info.md) +- [`substitute`](substitute.md) +- [`define_aggregate`](define_aggregate.md) +- [`can_substitute`](can_substitute.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_all_extents.md b/reference/meta/remove_all_extents.md new file mode 100644 index 0000000000..89ce63ae53 --- /dev/null +++ b/reference/meta/remove_all_extents.md @@ -0,0 +1,55 @@ +# remove_all_extents +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_all_extents(info type); +} +``` +* info[link info.md] + +## 概要 +配列型からすべての次元を除去する。[`std::remove_all_extents`](/reference/type_traits/remove_all_extents.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_all_extents`](/reference/type_traits/remove_all_extents.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_all_extents(^^int[3][4]) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_all_extents`](/reference/type_traits/remove_all_extents.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_const.md b/reference/meta/remove_const.md new file mode 100644 index 0000000000..992e080f49 --- /dev/null +++ b/reference/meta/remove_const.md @@ -0,0 +1,55 @@ +# remove_const +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_const(info type); +} +``` +* info[link info.md] + +## 概要 +型から`const`修飾を除去する。[`std::remove_const`](/reference/type_traits/remove_const.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_const`](/reference/type_traits/remove_const.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_const(^^const int) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_const`](/reference/type_traits/remove_const.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_cv.md b/reference/meta/remove_cv.md new file mode 100644 index 0000000000..c9a319f03e --- /dev/null +++ b/reference/meta/remove_cv.md @@ -0,0 +1,55 @@ +# remove_cv +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_cv(info type); +} +``` +* info[link info.md] + +## 概要 +型からCV修飾(`const`と`volatile`)を除去する。[`std::remove_cv`](/reference/type_traits/remove_cv.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_cv`](/reference/type_traits/remove_cv.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_cv(^^const volatile int) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_cv`](/reference/type_traits/remove_cv.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_cvref.md b/reference/meta/remove_cvref.md new file mode 100644 index 0000000000..61d2aaa246 --- /dev/null +++ b/reference/meta/remove_cvref.md @@ -0,0 +1,55 @@ +# remove_cvref +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_cvref(info type); +} +``` +* info[link info.md] + +## 概要 +型からCV修飾と参照を除去する。[`std::remove_cvref`](/reference/type_traits/remove_cvref.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_cvref`](/reference/type_traits/remove_cvref.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_cvref(^^const int&) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_cvref`](/reference/type_traits/remove_cvref.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_extent.md b/reference/meta/remove_extent.md new file mode 100644 index 0000000000..0a9b2880de --- /dev/null +++ b/reference/meta/remove_extent.md @@ -0,0 +1,55 @@ +# remove_extent +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_extent(info type); +} +``` +* info[link info.md] + +## 概要 +配列型から最初の次元を除去する。[`std::remove_extent`](/reference/type_traits/remove_extent.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_extent`](/reference/type_traits/remove_extent.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_extent(^^int[3]) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_extent`](/reference/type_traits/remove_extent.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_pointer.md b/reference/meta/remove_pointer.md new file mode 100644 index 0000000000..1b6d104f5a --- /dev/null +++ b/reference/meta/remove_pointer.md @@ -0,0 +1,55 @@ +# remove_pointer +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_pointer(info type); +} +``` +* info[link info.md] + +## 概要 +型からポインタを除去する。[`std::remove_pointer`](/reference/type_traits/remove_pointer.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_pointer`](/reference/type_traits/remove_pointer.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_pointer(^^int*) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_pointer`](/reference/type_traits/remove_pointer.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_reference.md b/reference/meta/remove_reference.md new file mode 100644 index 0000000000..3cb7352864 --- /dev/null +++ b/reference/meta/remove_reference.md @@ -0,0 +1,55 @@ +# remove_reference +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_reference(info type); +} +``` +* info[link info.md] + +## 概要 +型から参照を除去する。[`std::remove_reference`](/reference/type_traits/remove_reference.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_reference`](/reference/type_traits/remove_reference.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_reference(^^int&) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_reference`](/reference/type_traits/remove_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/remove_volatile.md b/reference/meta/remove_volatile.md new file mode 100644 index 0000000000..aa49ecac5d --- /dev/null +++ b/reference/meta/remove_volatile.md @@ -0,0 +1,55 @@ +# remove_volatile +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info remove_volatile(info type); +} +``` +* info[link info.md] + +## 概要 +型から`volatile`修飾を除去する。[`std::remove_volatile`](/reference/type_traits/remove_volatile.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::remove_volatile`](/reference/type_traits/remove_volatile.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::remove_volatile(^^volatile int) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::remove_volatile`](/reference/type_traits/remove_volatile.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/return_type_of.md b/reference/meta/return_type_of.md new file mode 100644 index 0000000000..8c83c0e52e --- /dev/null +++ b/reference/meta/return_type_of.md @@ -0,0 +1,61 @@ +# return_type_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info return_type_of(info r); +} +``` +* info[link info.md] + +## 概要 +関数または関数型の戻り値型のリフレクションを取得する。 + + +## 戻り値 +`r`が関数または関数型を表す場合、その戻り値型のリフレクションを返す。 + + +## 例外 +`r`が関数または関数型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int f(); +double g(); + +int main() { + static_assert(std::meta::return_type_of(^^f) == ^^int); + static_assert(std::meta::return_type_of(^^g) == ^^double); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`parameters_of`](parameters_of.md) +- [`type_of`](type_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/size_of.md b/reference/meta/size_of.md new file mode 100644 index 0000000000..d27cfaf8c4 --- /dev/null +++ b/reference/meta/size_of.md @@ -0,0 +1,52 @@ +# size_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval size_t size_of(info r); +} +``` +* info[link info.md] + +## 概要 +型またはデータメンバのサイズを取得する。 + + +## 戻り値 +`r`が型を表す場合は`sizeof`相当の値を、非静的データメンバを表す場合はそのメンバのサイズを返す。 + + +## 例外 +`r`が型または非静的データメンバを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +int main() { + static_assert(std::meta::size_of(^^int) == sizeof(int)); + static_assert(std::meta::size_of(^^double) == sizeof(double)); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/source_location_of.md b/reference/meta/source_location_of.md new file mode 100644 index 0000000000..4ad4007dc4 --- /dev/null +++ b/reference/meta/source_location_of.md @@ -0,0 +1,53 @@ +# source_location_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::source_location source_location_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションのソース位置を取得する。 + + +## 戻り値 +`r`が表すエンティティが宣言されたソース位置を[`std::source_location`](/reference/source_location/source_location.md)として返す。 + + +## 例 +```cpp example +#include +#include + +struct MyClass {}; + +int main() { + constexpr auto loc = std::meta::source_location_of(^^MyClass); + std::println("{}:{}", loc.file_name(), loc.line()); +} +``` +* file_name[link /reference/source_location/source_location/file_name.md] +* line[link /reference/source_location/source_location/line.md] + +#### 出力例 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/static_data_members_of.md b/reference/meta/static_data_members_of.md new file mode 100644 index 0000000000..c0ea8ce27a --- /dev/null +++ b/reference/meta/static_data_members_of.md @@ -0,0 +1,70 @@ +# static_data_members_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector static_data_members_of(info type, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスの静的データメンバのリフレクションを取得する。 + + +## 戻り値 +`type`が完全型のクラスを表す場合、アクセスコンテキスト`ctx`でアクセス可能な静的データメンバのリフレクションを格納した`vector`を返す。 + + +## 例外 +`r`が完全型のクラスを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct S { + static int count; + static constexpr double pi = 3.14; + int instance_var; +}; + +int main() { + constexpr auto statics = std::meta::static_data_members_of( + ^^S, std::meta::access_context::unchecked()); + static_assert(statics.size() == 2); + + template for (constexpr auto m : statics) { + std::println("{}", std::meta::identifier_of(m)); + } +} +``` +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::identifier_of[link identifier_of.md] + +### 出力 +``` +count +pi +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/subobjects_of.md b/reference/meta/subobjects_of.md new file mode 100644 index 0000000000..b8c5a327fc --- /dev/null +++ b/reference/meta/subobjects_of.md @@ -0,0 +1,70 @@ +# subobjects_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector subobjects_of(info type, access_context ctx); +} +``` +* info[link info.md] +* access_context[link access_context.md] + +## 概要 +クラスの基底クラスと非静的データメンバを統合して取得する。 + + +## 戻り値 +`type`が完全型のクラスを表す場合、アクセスコンテキスト`ctx`でアクセス可能な直接基底クラス関係と非静的データメンバのリフレクションを格納した[`std::vector`](/reference/vector/vector.md)オブジェクトを返す。基底クラスが非静的データメンバより先に配置される。 + + +## 例外 +`r`が完全型のクラスを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +struct Base { int b; }; +struct Derived : Base { int d; }; + +int main() { + constexpr auto subs = std::meta::subobjects_of( + ^^Derived, std::meta::access_context::unchecked()); + + // 基底クラスが先、非静的データメンバが後 + template for (constexpr auto s : subs) { + std::println("{}", std::meta::display_string_of(s)); + } +} +``` +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::display_string_of[link display_string_of.md] + +#### 出力例 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`bases_of`](bases_of.md) +- [`nonstatic_data_members_of`](nonstatic_data_members_of.md) + + +## 参照 +- [P3293R3 Splicing a base class subobject](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3293r3.html) diff --git a/reference/meta/substitute.md b/reference/meta/substitute.md new file mode 100644 index 0000000000..cbe375fbe6 --- /dev/null +++ b/reference/meta/substitute.md @@ -0,0 +1,60 @@ +# substitute +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + template > + consteval info substitute(info templ, R&& arguments); +} +``` +* info[link info.md] +* reflection_range[link reflection_range.md] + +## 概要 +テンプレートにテンプレート引数を適用する。 + + +## 戻り値 +テンプレート`templ`に`arguments`を置換した結果の特殊化のリフレクションを返す。 + + +## 例外 +[`can_substitute`](can_substitute.md)`(templ, arguments)`が`false`の場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + constexpr auto vec_int = std::meta::substitute(^^std::vector, {^^int}); + static_assert(vec_int == ^^std::vector); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`can_substitute`](can_substitute.md) +- [`template_of`](template_of.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/symbol_of.md b/reference/meta/symbol_of.md new file mode 100644 index 0000000000..34f271d4cd --- /dev/null +++ b/reference/meta/symbol_of.md @@ -0,0 +1,65 @@ +# symbol_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] +* u8symbol_of[meta alias] + +```cpp +namespace std::meta { + consteval string_view symbol_of(operators op); + consteval u8string_view u8symbol_of(operators op); +} +``` +* operators[link operators.md] + +## 概要 +演算子の種類から記号文字列を取得する。 + + +## 戻り値 +演算子`op`に対応する記号文字列を返す。 + + +## 例 +```cpp example +#include +#include + +struct S { + bool operator==(const S&) const = default; +}; + +int main() { + template for (constexpr auto m : + std::meta::members_of(^^S, std::meta::access_context::unchecked())) { + if constexpr (std::meta::is_operator_function(m)) { + std::println("演算子: {}", std::meta::symbol_of(std::meta::operator_of(m))); + } + } +} +``` +* std::meta::members_of[link members_of.md] +* std::meta::access_context[link access_context.md] +* unchecked[link access_context/unchecked.md] +* std::meta::is_operator_function[link is_operator_function.md] +* std::meta::operator_of[link operator_of.md] + +### 出力 +``` +演算子: == +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/template_arguments_of.md b/reference/meta/template_arguments_of.md new file mode 100644 index 0000000000..55ff86f5a2 --- /dev/null +++ b/reference/meta/template_arguments_of.md @@ -0,0 +1,58 @@ +# template_arguments_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::vector template_arguments_of(info r); +} +``` +* info[link info.md] + +## 概要 +テンプレートの特殊化のテンプレート引数のリフレクションを取得する。 + + +## 戻り値 +`r`がテンプレートの特殊化を表す場合、そのテンプレート引数のリフレクションを格納した[`std::vector`](/reference/vector/vector.md)オブジェクトを返す。[`has_template_arguments`](has_template_arguments.md)`(r)`が`true`であることが事前条件となる。 + + +## 例外 +[`has_template_arguments`](has_template_arguments.md)`(r)`が`false`の場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + constexpr auto args = std::meta::template_arguments_of(^^std::vector); + static_assert(args[0] == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`template_of`](template_of.md) +- [`substitute`](substitute.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/template_of.md b/reference/meta/template_of.md new file mode 100644 index 0000000000..0d6ec97ed6 --- /dev/null +++ b/reference/meta/template_of.md @@ -0,0 +1,57 @@ +# template_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info template_of(info r); +} +``` +* info[link info.md] + +## 概要 +テンプレートの特殊化からテンプレート自体のリフレクションを取得する。 + + +## 戻り値 +`r`がテンプレートの特殊化を表す場合、そのテンプレートのリフレクションを返す。[`has_template_arguments`](has_template_arguments.md)`(r)`が`true`であることが事前条件となる。 + + +## 例外 +[`has_template_arguments`](has_template_arguments.md)`(r)`が`false`の場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::template_of(^^std::vector) == ^^std::vector); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`template_arguments_of`](template_arguments_of.md) +- [`substitute`](substitute.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/tuple_element.md b/reference/meta/tuple_element.md new file mode 100644 index 0000000000..8949c32fc7 --- /dev/null +++ b/reference/meta/tuple_element.md @@ -0,0 +1,60 @@ +# tuple_element +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info tuple_element(size_t index, info type); +} +``` +* info[link info.md] + +## 概要 +[`std::tuple`](/reference/tuple/tuple.md)や[`std::pair`](/reference/utility/pair.md)などのtuple-like型の指定位置の要素型を取得する。[`std::tuple_element`](/reference/tuple/tuple_element.md)に対応する。 + + +## 戻り値 +`type`が表す型の`index`番目の要素型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + using T = std::tuple; + static_assert(std::meta::tuple_element(0, ^^T) == ^^int); + static_assert(std::meta::tuple_element(1, ^^T) == ^^double); + static_assert(std::meta::tuple_element(2, ^^T) == ^^char); +} +``` +* std::meta::tuple_element[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`tuple_size`](tuple_size.md) +- [`std::tuple_element`](/reference/tuple/tuple_element.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/tuple_size.md b/reference/meta/tuple_size.md new file mode 100644 index 0000000000..f8f4f34d0a --- /dev/null +++ b/reference/meta/tuple_size.md @@ -0,0 +1,59 @@ +# tuple_size +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::size_t tuple_size(info type); +} +``` +* info[link info.md] + +## 概要 +[`std::tuple`](/reference/tuple/tuple.md)や[`std::pair`](/reference/utility/pair.md)などのtuple-like型の要素数を取得する。[`std::tuple_size`](/reference/tuple/tuple_size.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::tuple_size`](/reference/tuple/tuple_size.md)相当の値を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include +#include + +int main() { + static_assert(std::meta::tuple_size(^^std::tuple) == 3); + static_assert(std::meta::tuple_size(^^std::pair) == 2); +} +``` +* std::meta::tuple_size[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`tuple_element`](tuple_element.md) +- [`std::tuple_size`](/reference/tuple/tuple_size.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/type_of.md b/reference/meta/type_of.md new file mode 100644 index 0000000000..acb930cee6 --- /dev/null +++ b/reference/meta/type_of.md @@ -0,0 +1,53 @@ +# type_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info type_of(info r); +} +``` +* info[link info.md] + +## 概要 +リフレクションが表すエンティティの型のリフレクションを取得する。 + + +## 戻り値 +`r`が表す値、オブジェクト、変数、関数、非静的データメンバ、ビットフィールド、列挙子、基底クラス関係、データメンバ仕様、または関数パラメータの型のリフレクションを返す。 + + + +## 例外 +`r`が型を持つエンティティを表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + +## 例 +```cpp example +#include + +int x = 42; + +int main() { + static_assert(std::meta::type_of(^^x) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/type_order.md b/reference/meta/type_order.md new file mode 100644 index 0000000000..cb83c81289 --- /dev/null +++ b/reference/meta/type_order.md @@ -0,0 +1,55 @@ +# type_order +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval strong_ordering type_order(info type_a, info type_b); +} +``` +* info[link info.md] + +## 概要 +2つの型のリフレクション間の順序を取得する。[`std::meta::info`](info.md)は`<=>`をサポートしないが、この関数により型のリフレクション間で一貫した全順序を得ることができる。 + + +## 戻り値 +`type_a`と`type_b`が型を表す場合、それらの間の実装定義の全順序を[`strong_ordering`](/reference/compare/strong_ordering.md)として返す。 + + +## 例外 +`type_a`または`type_b`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + // 同じ型の比較は equal + static_assert(std::meta::type_order(^^int, ^^int) == std::strong_ordering::equal); + // 異なる型は less または greater(実装定義) + static_assert(std::meta::type_order(^^int, ^^double) != std::strong_ordering::equal); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/type_underlying_type.md b/reference/meta/type_underlying_type.md new file mode 100644 index 0000000000..337948f8ba --- /dev/null +++ b/reference/meta/type_underlying_type.md @@ -0,0 +1,57 @@ +# type_underlying_type +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info type_underlying_type(info type); +} +``` +* info[link info.md] + +## 概要 +列挙型の基底型を取得する。[`std::underlying_type`](/reference/type_traits/underlying_type.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::underlying_type`](/reference/type_traits/underlying_type.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include + +enum Color : int { red, green, blue }; + +int main() { + static_assert(std::meta::type_underlying_type(^^Color) == ^^int); +} +``` + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::underlying_type`](/reference/type_traits/underlying_type.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/unwrap_ref_decay.md b/reference/meta/unwrap_ref_decay.md new file mode 100644 index 0000000000..a603ec0d6e --- /dev/null +++ b/reference/meta/unwrap_ref_decay.md @@ -0,0 +1,57 @@ +# unwrap_ref_decay +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info unwrap_ref_decay(info type); +} +``` +* info[link info.md] + +## 概要 +`decay`適用後に[`std::reference_wrapper`](/reference/functional/reference_wrapper.md)を参照型に展開する。[`std::unwrap_ref_decay`](/reference/type_traits/unwrap_ref_decay.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::unwrap_ref_decay`](/reference/type_traits/unwrap_ref_decay.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::unwrap_ref_decay(^^std::reference_wrapper) == ^^int&); +} +``` +* std::reference_wrapper[link /reference/functional/reference_wrapper.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::unwrap_ref_decay`](/reference/type_traits/unwrap_ref_decay.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/unwrap_reference.md b/reference/meta/unwrap_reference.md new file mode 100644 index 0000000000..2cb033cc11 --- /dev/null +++ b/reference/meta/unwrap_reference.md @@ -0,0 +1,58 @@ +# unwrap_reference +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info unwrap_reference(info type); +} +``` +* info[link info.md] + +## 概要 +[`std::reference_wrapper`](/reference/functional/reference_wrapper.md)を参照型に展開する。[`std::unwrap_reference`](/reference/type_traits/unwrap_reference.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::unwrap_reference`](/reference/type_traits/unwrap_reference.md)相当の変換を適用した結果の型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::unwrap_reference(^^std::reference_wrapper) == ^^int&); + static_assert(std::meta::unwrap_reference(^^int) == ^^int); +} +``` +* std::reference_wrapper[link /reference/functional/reference_wrapper.md] + +### 出力 +``` +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`std::unwrap_reference`](/reference/type_traits/unwrap_reference.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/variable_of.md b/reference/meta/variable_of.md new file mode 100644 index 0000000000..a9776322fa --- /dev/null +++ b/reference/meta/variable_of.md @@ -0,0 +1,68 @@ +# variable_of +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info variable_of(info r); +} +``` +* info[link info.md] + +## 概要 +関数パラメータに対応するパラメータ変数のリフレクションを取得する。 + + +## 戻り値 +`r`が関数パラメータを表す場合、そのパラメータ変数のリフレクションを返す。 + + +## 備考 +この関数は、関数の定義内でのみ使用可能である。関数の宣言のみでは、パラメータ変数が存在しないため使用できない。 + + +## 例外 +`r`が関数パラメータを表さない場合、または関数定義のスコープ外で呼ばれた場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +void func(int x, double y) { + // 関数定義内でvariable_of()を使用してパラメータ変数にアクセス + template for (constexpr auto p : std::meta::parameters_of(^^func)) { + std::println("{} = {}", std::meta::identifier_of(p), + [:std::meta::variable_of(p):]); + } +} + +int main() { + func(42, 3.14); +} +``` +* std::meta::parameters_of[link parameters_of.md] +* std::meta::identifier_of[link identifier_of.md] + +### 出力 +``` +x = 42 +y = 3.14 +``` + + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 参照 +- [P3096R12 Function Parameter Reflection in Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3096r12.pdf) diff --git a/reference/meta/variant_alternative.md b/reference/meta/variant_alternative.md new file mode 100644 index 0000000000..c23ddfef01 --- /dev/null +++ b/reference/meta/variant_alternative.md @@ -0,0 +1,60 @@ +# variant_alternative +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval info variant_alternative(std::size_t index, info type); +} +``` +* info[link info.md] + +## 概要 +[`std::variant`](/reference/variant/variant.md)の指定位置の候補型を取得する。[`std::variant_alternative`](/reference/variant/variant_alternative.md)に対応する。 + + +## 戻り値 +`type`が表す型の`index`番目の候補型のリフレクションを返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + using V = std::variant; + static_assert(std::meta::variant_alternative(0, ^^V) == ^^int); + static_assert(std::meta::variant_alternative(1, ^^V) == ^^double); + static_assert(std::meta::variant_alternative(2, ^^V) == ^^char); +} +``` +* std::meta::variant_alternative[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`variant_size`](variant_size.md) +- [`std::variant_alternative`](/reference/variant/variant_alternative.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/meta/variant_size.md b/reference/meta/variant_size.md new file mode 100644 index 0000000000..f1a1751dcd --- /dev/null +++ b/reference/meta/variant_size.md @@ -0,0 +1,57 @@ +# variant_size +* meta[meta header] +* std::meta[meta namespace] +* function[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std::meta { + consteval std::size_t variant_size(info type); +} +``` +* info[link info.md] + +## 概要 +[`std::variant`](/reference/variant/variant.md)の候補型の数を取得する。[`std::variant_size`](/reference/variant/variant_size.md)に対応する。 + + +## 戻り値 +`type`が表す型に対して[`std::variant_size`](/reference/variant/variant_size.md)相当の値を返す。 + + +## 例外 +`type`が型を表さない場合、[`std::meta::exception`](exception.md)例外を送出する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::meta::variant_size(^^std::variant) == 3); +} +``` +* std::meta::variant_size[color ff0000] + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [`variant_alternative`](variant_alternative.md) +- [`std::variant_size`](/reference/variant/variant_size.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/type_traits.md b/reference/type_traits.md index 0ac382afca..7a920f334e 100644 --- a/reference/type_traits.md +++ b/reference/type_traits.md @@ -36,6 +36,7 @@ | [`is_union`](type_traits/is_union.md) | 型が共用型か調べる (class template) | C++11 | | [`is_class`](type_traits/is_class.md) | 型がクラス型か調べる (class template) | C++11 | | [`is_function`](type_traits/is_function.md) | 型が関数型か調べる (class template) | C++11 | +| [`is_reflection`](type_traits/is_reflection.md) | 型がリフレクション型か調べる (class template) | C++26 | ## 組み合わせた型 @@ -69,6 +70,7 @@ | [`is_final`](type_traits/is_final.md) | 型に`final`が付いているかを調べる (class template) | C++14 | | [`is_aggregate`](type_traits/is_aggregate.md) | 型が集成体かを調べる (class template) | C++17 | | [`is_implicit_lifetime`](type_traits/is_implicit_lifetime.md) | 型が暗黙的に構築されるかを調べる (class template) | C++23 | +| [`is_consteval_only`](type_traits/is_consteval_only.md) | 型がconsteval-only型か調べる (class template) | C++26 | | [`is_signed`](type_traits/is_signed.md) | 型が符号付き算術型か調べる (class template) | C++11 | | [`is_unsigned`](type_traits/is_unsigned.md) | 型が符号無し算術型か調べる (class template) | C++11 | | [`is_bounded_array`](type_traits/is_bounded_array.md) | 型が要素数の判明している配列型かを調べる (class template) | C++20 | diff --git a/reference/type_traits/aligned_storage.md b/reference/type_traits/aligned_storage.md index 0bebec2a6b..467b1aad3f 100644 --- a/reference/type_traits/aligned_storage.md +++ b/reference/type_traits/aligned_storage.md @@ -37,7 +37,7 @@ namespace std { - C++11 : [POD型](is_pod.md) - C++20 : [トリビアル型](is_trivial.md) -`Align`のデフォルト値は、`Len`よりも大きくない、最も厳格なアライメント要件を持つ、C++の何らかのオブジェクト型のアラインメント値。 +`Align`のデフォルト値は、`Len`よりも大きくない、最も厳格なアライメント要件を持つ、C++の何らかのオブジェクト型のアライメント値。 ## 非推奨の詳細 (C++23) diff --git a/reference/type_traits/is_consteval_only.md b/reference/type_traits/is_consteval_only.md new file mode 100644 index 0000000000..5700152708 --- /dev/null +++ b/reference/type_traits/is_consteval_only.md @@ -0,0 +1,69 @@ +# is_consteval_only +* type_traits[meta header] +* std[meta namespace] +* class template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + template + struct is_consteval_only; + + template + inline constexpr bool is_consteval_only_v = is_consteval_only::value; +} +``` + +## 概要 +型`T`がconsteval-only型であるかを判定する。 + +consteval-only型とは、コンパイル時にのみ存在でき、実行時には存在できない型である。[`std::meta::info`](/reference/meta/info.md)やそれを含む複合型が該当する。 + + +## 要件 +`remove_all_extents_t`が完全型であるか、CV修飾された`void`であること。 + + +## 効果 +`is_consteval_only`は、型`T`がconsteval-only型であれば[`true_type`](true_type.md)から派生し、そうでなければ[`false_type`](false_type.md)から派生する。 + + +## 例 +```cpp example +#include +#include + +struct S { + std::meta::info r; // consteval-only型のメンバを持つ +}; + +int main() { + static_assert(std::is_consteval_only_v); + static_assert(std::is_consteval_only_v); + static_assert(!std::is_consteval_only_v); +} +``` + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [ICC](/implementation.md#icc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) +- [`std::meta::info`](/reference/meta/info.md) +- [`is_reflection`](is_reflection.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html) diff --git a/reference/type_traits/is_reflection.md b/reference/type_traits/is_reflection.md new file mode 100644 index 0000000000..f1d42740ac --- /dev/null +++ b/reference/type_traits/is_reflection.md @@ -0,0 +1,59 @@ +# is_reflection +* type_traits[meta header] +* std[meta namespace] +* class template[meta id-type] +* cpp26[meta cpp] + +```cpp +namespace std { + template + struct is_reflection; + + template + inline constexpr bool is_reflection_v = is_reflection::value; +} +``` + +## 概要 +型`T`がリフレクション型([`std::meta::info`](/reference/meta/info.md))であるかを判定する。 + + +## 効果 +`is_reflection`は、型`T`が[`std::meta::info`](/reference/meta/info.md)(CV修飾を許容する)であれば[`true_type`](true_type.md)から派生し、そうでなければ[`false_type`](false_type.md)から派生する。 + + +## 例 +```cpp example +#include +#include + +int main() { + static_assert(std::is_reflection_v); + static_assert(std::is_reflection_v); + static_assert(!std::is_reflection_v); +} +``` + +### 出力 +``` +``` + +## バージョン +### 言語 +- C++26 + +### 処理系 +- [Clang](/implementation.md#clang): ?? +- [GCC](/implementation.md#gcc): ?? +- [ICC](/implementation.md#icc): ?? +- [Visual C++](/implementation.md#visual_cpp): ?? + + +## 関連項目 +- [C++26 静的リフレクション](/lang/cpp26/reflection.md) +- [`std::meta::info`](/reference/meta/info.md) +- [`std::meta::is_reflection_type`](/reference/meta/is_reflection_type.md) + + +## 参照 +- [P2996R13 Reflection for C++26](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html)