GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::meta::is_operator_function - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. meta
  3. is_operator_function

最終更新日時: 2026年05月07日 12時33分06秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<meta>

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

namespace std::meta {
  consteval bool is_operator_function(info r);
}

概要

演算子関数(operator+、operator==など、operatorキーワードで定義される関数)であるかを判定する。代入演算子operator=も演算子関数に含まれる。

戻り値

rが演算子関数を表す場合にtrueを返す。

例

#include <meta>
#include <print>

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::define_static_array(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));
    }
  }
}

出力例

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: ??
  • GCC: 16 (-freflection オプション指定) ✅
  • Visual C++: ??

参照

  • P2996R13 Reflection for C++26
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.