Files
2025-10-25 03:02:53 +03:00

112 lines
6.3 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[meta.reflection.operators]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#operators)
### 21.4.5 Operator representations [meta.reflection.operators]
[🔗](#itemdecl:1)
`enum class [operators](#lib:operators "21.4.5Operator representations[meta.reflection.operators]") {
see below;
};
using enum operators;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3566)
The enumeration type operators specifies
constants used to identify operators that can be overloaded,
with the meanings listed in Table [63](#tab:meta.reflection.operators "Table 63: Enum class operators")[.](#1.sentence-1)
The values of the constants are distinct[.](#1.sentence-2)
Table [63](#tab:meta.reflection.operators) — Enum class operators [[tab:meta.reflection.operators]](./tab:meta.reflection.operators)
| [🔗](#tab:meta.reflection.operators-row-1)<br>**Constant** | **Corresponding [*operator-function-id*](over.oper.general#nt:operator-function-id "12.4.1General[over.oper.general]")** | **Operator symbol name** |
| --- | --- | --- |
| [🔗](#tab:meta.reflection.operators-row-2)<br>op_new | operator new | new |
| [🔗](#tab:meta.reflection.operators-row-3)<br>op_delete | operator delete | delete |
| [🔗](#tab:meta.reflection.operators-row-4)<br>op_array_new | operator new[] | new[] |
| [🔗](#tab:meta.reflection.operators-row-5)<br>op_array_delete | operator delete[] | delete[] |
| [🔗](#tab:meta.reflection.operators-row-6)<br>op_co_await | operator co_await | co_await |
| [🔗](#tab:meta.reflection.operators-row-7)<br>op_parentheses | operator() | () |
| [🔗](#tab:meta.reflection.operators-row-8)<br>op_square_brackets | operator[] | [] |
| [🔗](#tab:meta.reflection.operators-row-9)<br>op_arrow | operator-> | -> |
| [🔗](#tab:meta.reflection.operators-row-10)<br>op_arrow_star | operator->* | ->* |
| [🔗](#tab:meta.reflection.operators-row-11)<br>op_tilde | operator~ | ~ |
| [🔗](#tab:meta.reflection.operators-row-12)<br>op_exclamation | operator! | ! |
| [🔗](#tab:meta.reflection.operators-row-13)<br>op_plus | operator+ | + |
| [🔗](#tab:meta.reflection.operators-row-14)<br>op_minus | operator- | - |
| [🔗](#tab:meta.reflection.operators-row-15)<br>op_star | operator* | * |
| [🔗](#tab:meta.reflection.operators-row-16)<br>op_slash | operator/ | / |
| [🔗](#tab:meta.reflection.operators-row-17)<br>op_percent | operator% | % |
| [🔗](#tab:meta.reflection.operators-row-18)<br>op_caret | operator^ | ^ |
| [🔗](#tab:meta.reflection.operators-row-19)<br>op_ampersand | operator& | & |
| [🔗](#tab:meta.reflection.operators-row-20)<br>op_equals | operator= | = |
| [🔗](#tab:meta.reflection.operators-row-21)<br>op_pipe | operator| | | |
| [🔗](#tab:meta.reflection.operators-row-22)<br>op_plus_equals | operator+= | += |
| [🔗](#tab:meta.reflection.operators-row-23)<br>op_minus_equals | operator-= | -= |
| [🔗](#tab:meta.reflection.operators-row-24)<br>op_star_equals | operator*= | *= |
| [🔗](#tab:meta.reflection.operators-row-25)<br>op_slash_equals | operator/= | /= |
| [🔗](#tab:meta.reflection.operators-row-26)<br>op_percent_equals | operator%= | %= |
| [🔗](#tab:meta.reflection.operators-row-27)<br>op_caret_equals | operator^= | ^= |
| [🔗](#tab:meta.reflection.operators-row-28)<br>op_ampersand_equals | operator&= | &= |
| [🔗](#tab:meta.reflection.operators-row-29)<br>op_pipe_equals | operator|= | |= |
| [🔗](#tab:meta.reflection.operators-row-30)<br>op_equals_equals | operator== | == |
| [🔗](#tab:meta.reflection.operators-row-31)<br>op_exclamation_equals | operator!= | != |
| [🔗](#tab:meta.reflection.operators-row-32)<br>op_less | operator< | < |
| [🔗](#tab:meta.reflection.operators-row-33)<br>op_greater | operator> | > |
| [🔗](#tab:meta.reflection.operators-row-34)<br>op_less_equals | operator<= | <= |
| [🔗](#tab:meta.reflection.operators-row-35)<br>op_greater_equals | operator>= | >= |
| [🔗](#tab:meta.reflection.operators-row-36)<br>op_spaceship | operator<=> | <=> |
| [🔗](#tab:meta.reflection.operators-row-37)<br>op_ampersand_ampersand | operator&& | && |
| [🔗](#tab:meta.reflection.operators-row-38)<br>op_pipe_pipe | operator|| | || |
| [🔗](#tab:meta.reflection.operators-row-39)<br>op_less_less | operator<< | << |
| [🔗](#tab:meta.reflection.operators-row-40)<br>op_greater_greater | operator>> | >> |
| [🔗](#tab:meta.reflection.operators-row-41)<br>op_less_less_equals | operator<<= | <<= |
| [🔗](#tab:meta.reflection.operators-row-42)<br>op_greater_greater_equals | operator>>= | >>= |
| [🔗](#tab:meta.reflection.operators-row-43)<br>op_plus_plus | operator++ | ++ |
| [🔗](#tab:meta.reflection.operators-row-44)<br>op_minus_minus | operator-- | -- |
| [🔗](#tab:meta.reflection.operators-row-45)<br>op_comma | operator, | , |
[🔗](#lib:operator_of)
`consteval operators operator_of(info r);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3633)
*Returns*: The value of the enumerator from operators whose corresponding [*operator-function-id*](over.oper.general#nt:operator-function-id "12.4.1General[over.oper.general]") is the unqualified name of the entity represented by r[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3639)
*Throws*: meta::exception unlessr represents an operator function or operator function template[.](#3.sentence-1)
[🔗](#lib:symbol_of)
`consteval string_view symbol_of(operators op);
consteval u8string_view u8symbol_of(operators op);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3653)
*Returns*: A string_view or u8string_view containing the characters of the operator symbol name corresponding to op,
respectively encoded with the ordinary literal encoding or with UTF-8[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3659)
*Throws*: meta::exception unless
the value of op corresponds to one of the enumerators in operators[.](#5.sentence-1)