最終更新日時(UTC):
が更新

履歴 編集

function
<meta>

std::meta::symbol_of(C++26)

namespace std::meta {
  consteval string_view symbol_of(operators op);
  consteval u8string_view u8symbol_of(operators op);
}

概要

演算子の種類から記号文字列を取得する。

戻り値

演算子opに対応する記号文字列を返す。

#include <meta>
#include <print>

struct S {
  bool operator==(const S&) const = default;
};

int main() {
  template for (constexpr auto m :
      std::define_static_array(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)));
    }
  }
}

出力

演算子: ==
演算子: =
演算子: =

バージョン

言語

  • C++26

処理系

参照