Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 1.6 KB

File metadata and controls

68 lines (50 loc) · 1.6 KB

current_class

  • meta[meta header]
  • std::meta[meta namespace]
  • function[meta id-type]
  • cpp26[meta cpp]
namespace std::meta {
  consteval info current_class();
}
  • info[link info.md]

概要

current_class()を呼び出した時点で直接囲んでいるクラス(またはメンバ関数の所属するクラス)のリフレクションを返す。

戻り値

呼び出し位置を囲んでいるクラスのリフレクションを返す。メンバ関数内から呼ばれた場合は、そのメンバ関数が所属するクラスのリフレクションを返す。

例外

クラス(またはメンバ関数)の文脈で呼ばれていない場合、std::meta::exception例外を送出する。

#include <meta>
#include <print>

class MyClass {
public:
  static void info() {
    constexpr auto cls = std::meta::current_class();
    std::println("クラス名: {}", std::meta::identifier_of(cls));
  }
};

int main() {
  MyClass::info();
}
  • std::meta::current_class[color ff0000]
  • std::meta::identifier_of[link identifier_of.md]

出力例

クラス名: MyClass

バージョン

言語

  • C++26

処理系

関連項目

参照