This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,218 @@
[meta.reflection.access.context]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#access.context)
### 21.4.8 Access control context [meta.reflection.access.context]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L4997)
The access_context class is a non-aggregate type
that represents a namespace, class, or function
from which queries pertaining to access rules may be performed,
as well as the designating class ([[class.access.base]](class.access.base "11.8.3Accessibility of base classes and base class members")), if any[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5004)
An access_context has an associated scope and designating class[.](#2.sentence-1)
[🔗](#lib:access_context_)
namespace std::meta {struct access_context { access_context() = delete; consteval info scope() const; consteval info designating_class() const; static consteval access_context current() noexcept; static consteval access_context unprivileged() noexcept; static consteval access_context unchecked() noexcept; consteval access_context via(info cls) const; };}
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5024)
access_context is a structural type[.](#3.sentence-1)
Two values ac1 and ac2 of type access_context are template-argument-equivalent ([[temp.type]](temp.type "13.6Type equivalence"))
if ac1.scope() and ac2.scope() are template-argument-equivalent
and ac1.designating_class() and ac2.designating_class() are template-argument-equivalent[.](#3.sentence-2)
[🔗](#itemdecl:1)
`consteval info [scope](#lib:access_context,scope "21.4.8Access control context[meta.reflection.access.context]")() const;
consteval info [designating_class](#lib:access_context,designating_class "21.4.8Access control context[meta.reflection.access.context]")() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5039)
*Returns*: The access_context's associated scope
and designating class, respectively[.](#4.sentence-1)
[🔗](#itemdecl:2)
`static consteval access_context [current](#lib:access_context,current "21.4.8Access control context[meta.reflection.access.context]")() noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5050)
Given a program point P,
let *eval-point*(P) be the following program point:
- [(5.1)](#5.1)
If a potentially-evaluated subexpression ([[intro.execution]](intro.execution "6.10.1Sequential execution"))
of a default member initializer I for a member of class C ([[class.mem.general]](class.mem.general "11.4.1General"))
appears at P,
then a point determined as follows:
* [(5.1.1)](#5.1.1)
If an aggregate initialization is using I, *eval-point*(Q),
where Q is the point at which that aggregate initialization appears[.](#5.1.1.sentence-1)
* [(5.1.2)](#5.1.2)
Otherwise, if an initialization
by an inherited constructor ([[class.inhctor.init]](class.inhctor.init "11.9.4Initialization by inherited constructor")) is using I,
a point whose immediate scope is the class scope corresponding to C[.](#5.1.2.sentence-1)
* [(5.1.3)](#5.1.3)
Otherwise, a point whose immediate scope
is the function parameter scope
corresponding to the constructor definition that is using I[.](#5.1.3.sentence-1)
- [(5.2)](#5.2)
Otherwise, if a potentially-evaluated subexpression
of a default argument ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments")) appears at P, *eval-point*(Q),
where Q is the point at which the invocation of the function ([[expr.call]](expr.call "7.6.1.3Function call"))
using that default argument appears[.](#5.2.sentence-1)
- [(5.3)](#5.3)
Otherwise, if the immediate scope of P is a function parameter scope introduced by a declaration D,
and P appears either before the locus of D or within the trailing [*requires-clause*](temp.pre#nt:requires-clause "13.1Preamble[temp.pre]") of D,
a point whose immediate scope is the innermost scope enclosing the locus of D that is not a template parameter scope[.](#5.3.sentence-1)
- [(5.4)](#5.4)
Otherwise, if the immediate scope of P is a function parameter scope
introduced by a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1General[expr.prim.lambda.general]") L whose [*lambda-introducer*](expr.prim.lambda.general#nt:lambda-introducer "7.5.6.1General[expr.prim.lambda.general]") appears at point Q,
and P appears either within the [*trailing-return-type*](dcl.decl.general#nt:trailing-return-type "9.3.1General[dcl.decl.general]") or the trailing [*requires-clause*](temp.pre#nt:requires-clause "13.1Preamble[temp.pre]") of L, *eval-point*(Q)[.](#5.4.sentence-1)
- [(5.5)](#5.5)
Otherwise, if the innermost non-block scope enclosing P is the function parameter scope
introduced by a [*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1Preamble[dcl.pre]") ([[dcl.pre]](dcl.pre "9.1Preamble")),
a point whose immediate scope is that inhabited
by the outermost [*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1Preamble[dcl.pre]") D containing P such that each scope (if any) that intervenes between P and the function parameter scope introduced by D is either
* [(5.5.1)](#5.5.1)
a block scope or
* [(5.5.2)](#5.5.2)
a function parameter scope or lambda scope
introduced by a [*consteval-block-declaration*](dcl.pre#nt:consteval-block-declaration "9.1Preamble[dcl.pre]")[.](#5.5.sentence-1)
- [(5.6)](#5.6)
Otherwise, P[.](#5.6.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5114)
Given a scope S,
let *ctx-scope*(S) be the following scope:
- [(6.1)](#6.1)
If S is a class scope or namespace scope, S[.](#6.1.sentence-1)
- [(6.2)](#6.2)
Otherwise, if S is a function parameter scope
introduced by the declaration of a function, S[.](#6.2.sentence-1)
- [(6.3)](#6.3)
Otherwise, if S is a lambda scope
introduced by a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1General[expr.prim.lambda.general]") L,
the function parameter scope
corresponding to the call operator of the closure type of L[.](#6.3.sentence-1)
- [(6.4)](#6.4)
Otherwise, *ctx-scope*(S′),
where S′ is the parent scope of S[.](#6.4.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5135)
*Returns*: An access_context whose designating class is the null reflection
and whose scope represents the function, class, or namespace
whose corresponding function parameter scope, class scope, or namespace scope, respectively,
is *ctx-scope*(S),
where S is the immediate scope of *eval-point*(P) and P is the point at which the invocation of current lexically appears[.](#7.sentence-1)
[*Example [1](#example-1)*: struct A {int a = 0; consteval A(int p) : a(p) {}};struct B : A {using A::A; consteval B(int p, int q) : A(p * q) {} info s = access_context::current().scope();};struct C : B { using B::B; };
struct Agg {consteval bool eq(info rhs = access_context::current().scope()) {return s == rhs; } info s = access_context::current().scope();};
namespace NS {static_assert(Agg{}.s == access_context::current().scope()); // OKstatic_assert(Agg{}.eq()); // OKstatic_assert(B(1).s == ^^B); // OKstatic_assert(is_constructor(B{1, 2}.s) && parent_of(B{1, 2}.s) == ^^B); // OKstatic_assert(is_constructor(C{1, 2}.s) && parent_of(C{1, 2}.s) == ^^B); // OKauto fn() -> [:is_namespace(access_context::current().scope()) ? ^^int : ^^bool:]; static_assert(type_of(^^fn) == ^^auto()->int); // OKtemplate<auto R>struct TCls {consteval bool fn()requires (is_type(access_context::current().scope())) {return true; // OK, scope is TCls<R>.}}; static_assert(TCls<0>{}.fn()); // OK} — *end example*]
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5185)
*Remarks*: current is not an addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#8.sentence-1)
An invocation of current that appears at a program point P is value-dependent ([[temp.dep.constexpr]](temp.dep.constexpr "13.8.3.4Value-dependent expressions"))
if *eval-point*(P) is enclosed by a scope
corresponding to a templated entity[.](#8.sentence-2)
[🔗](#itemdecl:3)
`static consteval access_context [unprivileged](#lib:access_context,unprivileged "21.4.8Access control context[meta.reflection.access.context]")() noexcept;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5199)
*Returns*: An access_context whose designating class is the null reflection
and whose scope is the global namespace[.](#9.sentence-1)
[🔗](#itemdecl:4)
`static consteval access_context [unchecked](#lib:access_context,unchecked "21.4.8Access control context[meta.reflection.access.context]")() noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5210)
*Returns*: An access_context whose designating class and scope
are both the null reflection[.](#10.sentence-1)
[🔗](#itemdecl:5)
`static consteval access_context [via](#lib:access_context,via "21.4.8Access control context[meta.reflection.access.context]")(info cls) const;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5221)
*Returns*: An access_context whose scope is this->scope() and whose designating class is cls[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5226)
*Throws*: meta::exception unlesscls is either the null reflection
or a reflection of a complete class type[.](#12.sentence-1)

View File

@@ -0,0 +1,182 @@
[meta.reflection.access.queries]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#access.queries)
### 21.4.9 Member accessibility queries [meta.reflection.access.queries]
[🔗](#lib:is_accessible)
`consteval bool is_accessible(info r, access_context ctx);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5241)
Let *PARENT-CLS*(r) be:
- [(1.1)](#1.1)
If parent_of(r) represents a class C, then C[.](#1.1.sentence-1)
- [(1.2)](#1.2)
Otherwise, *PARENT-CLS*(parent_of(r))[.](#1.2.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5248)
Let *DESIGNATING-CLS*(r, ctx) be:
- [(2.1)](#2.1)
If ctx.designating_class() represents a class C, then C[.](#2.1.sentence-1)
- [(2.2)](#2.2)
Otherwise, *PARENT-CLS*(r)[.](#2.2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5255)
*Returns*:
- [(3.1)](#3.1)
If r represents an unnamed bit-field F,
then is_accessible(rH, ctx),
where rH represents a hypothetical non-static data member
of the class represented by *PARENT-CLS*(r) with the same access as F[.](#3.1.sentence-1)
[*Note [1](#note-1)*:
Unnamed bit-fields are treated as class members
for the purpose of is_accessible[.](#3.1.sentence-2)
— *end note*]
- [(3.2)](#3.2)
Otherwise, if r does not represent a class member
or a direct base class relationship,
then true[.](#3.2.sentence-1)
- [(3.3)](#3.3)
Otherwise, if r represents
* [(3.3.1)](#3.3.1)
a class member that is not a (possibly indirect or variant)
member of *DESIGNATING-CLS*(r, ctx) or
* [(3.3.2)](#3.3.2)
a direct base class relationship such that parent_of(r) does not represent *DESIGNATING-CLS*(r, ctx) or a (direct or indirect) base class thereof,
then false[.](#3.3.sentence-1)
- [(3.4)](#3.4)
Otherwise, if ctx.scope() is the null reflection,
then true[.](#3.4.sentence-1)
- [(3.5)](#3.5)
Otherwise, letting P be a program point whose immediate scope is the
function parameter scope, class scope, or namespace scope
corresponding to the
function, class, or namespace
represented by ctx.scope():
* [(3.5.1)](#3.5.1)
If r represents a direct base class relationship (D,B),
then true if base class B of *DESIGNATING-CLS*(r, ctx) is accessible at P ([[class.access.base]](class.access.base "11.8.3Accessibility of base classes and base class members"));
otherwise false[.](#3.5.1.sentence-1)
* [(3.5.2)](#3.5.2)
Otherwise, r represents a class member M; true if M would be accessible at P with the designating class ([[class.access.base]](class.access.base "11.8.3Accessibility of base classes and base class members")) as *DESIGNATING-CLS*(r, ctx) if the effect of any [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]")*s* ([[namespace.udecl]](namespace.udecl "9.10The using declaration")) were ignored[.](#3.5.2.sentence-1)
Otherwise, false[.](#3.5.2.sentence-2)
[*Note [2](#note-2)*:
The definitions of when a class member or base class is accessible from a point P do not consider whether a declaration of that entity is reachable from P[.](#3.sentence-2)
— *end note*]
[*Example [1](#example-1)*: consteval access_context fn() {return access_context::current();}class Cls {int mem; friend consteval access_context fn();public:static constexpr auto r = ^^mem;};
static_assert(is_accessible(Cls::r, fn())); // OKstatic_assert(!is_accessible(Cls::r, access_context::current())); // OKstatic_assert(is_accessible(Cls::r, access_context::unchecked())); // OK — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5330)
*Throws*: meta::exception if
- [(4.1)](#4.1)
r represents a class member
for which *PARENT-CLS*(r) is an incomplete class or
- [(4.2)](#4.2)
r represents a direct base class relationship (D,B) for which D is incomplete[.](#4.sentence-1)
[🔗](#lib:has_inaccessible_nonstatic_data_members)
`consteval bool has_inaccessible_nonstatic_data_members(info r, access_context ctx);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5349)
*Returns*: true if is_accessible(R, ctx) is false for any R in nonstatic_data_members_of(r, access_context::unchecked())[.](#5.sentence-1)
Otherwise, false[.](#5.sentence-2)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5355)
*Throws*: meta::exception unless
- [(6.1)](#6.1)
nonstatic_data_members_of(r, access_context::unchecked()) is a constant subexpression and
- [(6.2)](#6.2)
r does not represent a closure type[.](#6.sentence-1)
[🔗](#itemdecl:3)
`consteval bool has_inaccessible_bases(info r, access_context ctx);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5372)
*Returns*: true if is_accessible(R, ctx) is false for any R in bases_of(r, access_context::unchecked())[.](#7.sentence-1)
Otherwise, false[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5378)
*Throws*: meta::exception unlessbases_of(r, access_context::unchecked()) is a constant subexpression[.](#8.sentence-1)
[🔗](#lib:has_inaccessible_subobjects)
`consteval bool has_inaccessible_subobjects(info r, access_context ctx);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5391)
*Effects*: Equivalent to:return has_inaccessible_bases(r, ctx) || has_inaccessible_nonstatic_data_members(r, ctx);

View File

@@ -0,0 +1,103 @@
[meta.reflection.annotation]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#annotation)
### 21.4.18 Annotation reflection [meta.reflection.annotation]
[🔗](#lib:annotations_of)
`consteval vector<info> annotations_of(info item);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6930)
Let E be
- [(1.1)](#1.1)
the corresponding [*base-specifier*](class.derived.general#nt:base-specifier "11.7.1General[class.derived.general]") if item represents a direct base class relationship,
- [(1.2)](#1.2)
otherwise, the entity represented by item[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6940)
*Returns*: A vector containing all of the reflections R representing each annotation applying to each declaration of E that precedes either
some point in the evaluation context ([[expr.const]](expr.const "7.7Constant expressions")) or
a point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1Preamble[class.pre]") of the outermost class for which such a point is in a complete-class context[.](#2.sentence-1)
For any two reflections R1 and R2 in the returned vector,
if the annotation represented by R1 precedes the annotation represented by R2,
then R1 appears before R2[.](#2.sentence-2)
If R1 and R2 represent annotations from the same translation unit T,
any element in the returned vector between R1 and R2 represents an annotation from T[.](#2.sentence-3)
[*Note [1](#note-1)*:
The order in which two annotations appear is otherwise unspecified[.](#2.sentence-4)
— *end note*]
[*Example [1](#example-1)*: [[=1]] void f();[[=2, =3]] void g();void g [[=4]] ();
static_assert(annotations_of(^^f).size() == 1);static_assert(annotations_of(^^g).size() == 3);static_assert([: constant_of(annotations_of(^^g)[0]) :] == 2);static_assert(extract<int>(annotations_of(^^g)[1]) == 3);static_assert(extract<int>(annotations_of(^^g)[2]) == 4);
struct Option { bool value; };
struct C {[[=Option{true}]] int a; [[=Option{false}]] int b;};
static_assert(extract<Option>(annotations_of(^^C::a)[0]).value);static_assert(!extract<Option>(annotations_of(^^C::b)[0]).value);
template<class T>struct [[=42]] D { };
constexpr std::meta::info a1 = annotations_of(^^D<int>)[0];constexpr std::meta::info a2 = annotations_of(^^D<char>)[0];static_assert(a1 != a2);static_assert(constant_of(a1) == constant_of(a2));
[[=1]] int x, y;static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]); — *end example*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6991)
*Throws*: meta::exception unlessitem represents a
type,
type alias,
variable,
function,
namespace,
enumerator,
direct base class relationship, or
non-static data member[.](#3.sentence-1)
[🔗](#lib:annotations_of_with_type)
`consteval vector<info> annotations_of_with_type(info item, info type);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L7011)
*Returns*: A vector containing each element e of annotations_of(item) whereremove_const(type_of(e)) == remove_const(type) is true, preserving their order[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L7020)
*Throws*: meta::exception unless
- [(5.1)](#5.1)
annotations_of(item) is a constant expression and
- [(5.2)](#5.2)
dealias(type) represents a type that is complete
from some point in the evaluation context[.](#5.sentence-1)

View File

@@ -0,0 +1,128 @@
[meta.reflection.array]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#array)
### 21.4.15 Promoting to static storage arrays [meta.reflection.array]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6201)
The functions in this subclause promote compile-time storage into static storage[.](#1.sentence-1)
[🔗](#lib:reflect_constant_string)
`template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R>
consteval info reflect_constant_string(R&& r);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6211)
Let CharT be ranges::range_value_t<R>[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6214)
*Mandates*: CharT is one ofchar,wchar_t,char8_t,char16_t,char32_t[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6223)
Let V be the pack of values of type CharT whose elements are the corresponding elements of r,
except that if r refers to a string literal object,
then V does not include the trailing null terminator of r[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6229)
Let P be the template parameter object ([[temp.param]](temp.param "13.2Template parameters"))
of type const CharT[sizeof...(V) + 1] initialized with {V..., CharT()}[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6234)
*Returns*: ^^P[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6238)
[*Note [1](#note-1)*:
P is a potentially non-unique object ([[intro.object]](intro.object "6.8.2Object model"))[.](#7.sentence-1)
— *end note*]
[🔗](#lib:reflect_constant_array)
`template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R>
consteval info reflect_constant_array(R&& r);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6251)
Let T be ranges::range_value_t<R>[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6254)
*Mandates*: T is a structural type ([[temp.param]](temp.param "13.2Template parameters")),is_constructible_v<T, ranges::range_reference_t<R>> is true, andis_copy_constructible_v<T> is true[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6260)
Let V be the pack of values of type info of the same size as r,
where the ith element is reflect_constant(ei),
where ei is the ith element of r[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6266)
Let P be
- [(11.1)](#11.1)
If sizeof...(V) > 0 is true,
then the template parameter object ([[temp.param]](temp.param "13.2Template parameters"))
of type const T[sizeof...(V)] initialized with {[:V:]...}[.](#11.1.sentence-1)
- [(11.2)](#11.2)
Otherwise, the template parameter object
of type array<T, 0> initialized with {}[.](#11.2.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6280)
*Returns*: ^^P[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6284)
*Throws*: meta::exception unlessreflect_constant(e) is a constant subexpression
for every element e of r[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6290)
[*Note [2](#note-2)*:
P is a potentially non-unique object ([[intro.object]](intro.object "6.8.2Object model"))[.](#14.sentence-1)
— *end note*]

View File

@@ -0,0 +1,302 @@
[meta.reflection.define.aggregate]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#define.aggregate)
### 21.4.16 Reflection class definition generation [meta.reflection.define.aggregate]
[🔗](#lib:data_member_options)
namespace std::meta {struct data_member_options {struct *name-type* { // *exposition only*template<class T>requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<u8string, T>consteval *name-type*(T&&); template<class T>requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<string, T>consteval *name-type*(T&&); private: variant<u8string, string> *contents*; // *exposition only*};
optional<*name-type*> name;
optional<int> alignment;
optional<int> bit_width; bool no_unique_address = false; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6323)
The classes data_member_options and data_member_options::*name-type* are consteval-only types ([[basic.types.general]](basic.types.general "6.9.1General")),
and are not structural types ([[temp.param]](temp.param "13.2Template parameters"))[.](#1.sentence-1)
[🔗](#itemdecl:1)
`template<class T>
requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<u8string, T>
consteval name-type(T&& value);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6336)
*Effects*: Initializes *contents* with u8string(std::forward<T>(value))[.](#2.sentence-1)
[🔗](#itemdecl:2)
`template<class T>
requires [constructible_from](concept.constructible#concept:constructible_from "18.4.11Concept constructible_­from[concept.constructible]")<string, T>
consteval name-type(T&& value);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6349)
*Effects*: Initializes *contents* with string(std::forward<T>(value))[.](#3.sentence-1)
[*Note [1](#note-1)*:
The class *name-type* allows
the function data_member_spec to accept
an ordinary string literal (or string_view, string, etc[.](#3.sentence-2))
or a UTF-8 string literal (or u8string_view, u8string, etc[.](#3.sentence-3))
equally well[.](#3.sentence-4)
[*Example [1](#example-1)*: consteval void fn() { data_member_options o1 = {.name = "ordinary_literal_encoding"};
data_member_options o2 = {.name = u8"utf8_encoding"};} — *end example*]
— *end note*]
[🔗](#lib:data_member_spec)
`consteval info data_member_spec(info type, data_member_options options);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6376)
*Returns*: A reflection of a data member description(T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General")) where
- [(4.1)](#4.1)
T is the type represented by dealias(type),
- [(4.2)](#4.2)
N is either the identifier encoded by options.name or ⊥ if options.name does not contain a value,
- [(4.3)](#4.3)
A is either the alignment value held by options.alignment or ⊥ if options.alignment does not contain a value,
- [(4.4)](#4.4)
W is either the value held by options.bit_width or ⊥ if options.bit_width does not contain a value, and
- [(4.5)](#4.5)
NUA is the value held by options.no_unique_address[.](#4.sentence-1)
[*Note [2](#note-2)*:
The returned reflection value is primarily useful
in conjunction with define_aggregate;
it can also be queried by certain other functions in std::meta (e.g., type_of, identifier_of)[.](#4.sentence-2)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6402)
*Throws*: meta::exception unless the following conditions are met:
- [(5.1)](#5.1)
dealias(type) represents either an object type or a reference type;
- [(5.2)](#5.2)
if options.name contains a value, then:
* [(5.2.1)](#5.2.1)
holds_alternative<u8string>(options.name->*contents*) is true and get<u8string>(options.name->*contents*) contains a valid identifier ([[lex.name]](lex.name "5.11Identifiers"))
that is not a keyword ([[lex.key]](lex.key "5.12Keywords"))
when interpreted with UTF-8, or
* [(5.2.2)](#5.2.2)
holds_alternative<string>(options.name->*contents*) is true and get<string>(options.name->*contents*) contains a valid identifier ([[lex.name]](lex.name "5.11Identifiers"))
that is not a keyword ([[lex.key]](lex.key "5.12Keywords"))
when interpreted with the ordinary literal encoding;
[*Note [3](#note-3)*:
The name corresponds to the spelling of an identifier token
after phase 6 of translation ([[lex.phases]](lex.phases "5.2Phases of translation"))[.](#5.2.sentence-1)
Lexical constructs like [*universal-character-name*](lex.universal.char#nt:universal-character-name "5.3.2Universal character names[lex.universal.char]")*s* ([[lex.universal.char]](lex.universal.char "5.3.2Universal character names")) are not processed
and will cause evaluation to fail[.](#5.2.sentence-2)
For example, R"(\u03B1)" is an invalid identifier
and is not interpreted as "α"[.](#5.2.sentence-3)
— *end note*]
- [(5.3)](#5.3)
if options.name does not contain a value,
then options.bit_width contains a value;
- [(5.4)](#5.4)
if options.bit_width contains a value V, then
* [(5.4.1)](#5.4.1)
is_integral_type(type) || is_enum_type(type) is true,
* [(5.4.2)](#5.4.2)
options.alignment does not contain a value,
* [(5.4.3)](#5.4.3)
options.no_unique_address is false, and
* [(5.4.4)](#5.4.4)
if V equals 0,
then options.name does not contain a value; and
- [(5.5)](#5.5)
if options.alignment contains a value,
it is an alignment value ([[basic.align]](basic.align "6.8.3Alignment"))
not less than alignment_of(type)[.](#5.sentence-1)
[🔗](#lib:is_data_member_spec)
`consteval bool is_data_member_spec(info r);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6462)
*Returns*: true if r represents a data member description[.](#6.sentence-1)
Otherwise, false[.](#6.sentence-2)
[🔗](#lib:define_aggregate)
`template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>
consteval info define_aggregate(info class_type, R&& mdescrs);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6475)
Let C be the class represented by class_type and rK be the Kth reflection value in mdescrs[.](#7.sentence-1)
For every rK in mdescrs,
let (TK,NK,AK,WK,NUAK) be
the corresponding data member description represented by rK[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6482)
*Constant When*:
- [(8.1)](#8.1)
C is incomplete from every point in the evaluation context;
[*Note [4](#note-4)*:
C can be a class template specialization
for which there is a reachable definition of the class template[.](#8.1.sentence-1)
In this case,
the injected declaration is an explicit specialization[.](#8.1.sentence-2)
— *end note*]
- [(8.2)](#8.2)
is_data_member_spec(rK) is true for every rK;
- [(8.3)](#8.3)
is_complete_type(TK) is true for every rK; and
- [(8.4)](#8.4)
for every pair (rK,rL) where K<L,
if NK is not ⊥ and NL is not ⊥,
then either:
* [(8.4.1)](#8.4.1)
NK != NL is true or
* [(8.4.2)](#8.4.2)
NK == u8"_" is true[.](#8.sentence-1)
[*Note [5](#note-5)*:
Every provided identifier is unique or "_"[.](#8.4.2.sentence-2)
— *end note*]
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6512)
*Effects*: Produces an injected declaration D ([[expr.const]](expr.const "7.7Constant expressions"))
that defines C and has properties as follows:
- [(9.1)](#9.1)
The target scope of D is the scope to which C belongs ([[basic.scope.scope]](basic.scope.scope "6.4.1General"))[.](#9.1.sentence-1)
- [(9.2)](#9.2)
The locus of D follows immediately after the core constant expression
currently under evaluation[.](#9.2.sentence-1)
- [(9.3)](#9.3)
The characteristic sequence of D ([[expr.const]](expr.const "7.7Constant expressions"))
is the sequence of reflection values rK[.](#9.3.sentence-1)
- [(9.4)](#9.4)
If C is a specialization of a templated class T,
and C is not a local class,
then D is an explicit specialization of T[.](#9.4.sentence-1)
- [(9.5)](#9.5)
For each rK,
there is a corresponding entity MK belonging to the class scope of D with the following properties:
* [(9.5.1)](#9.5.1)
If NK is ⊥, MK is an unnamed bit-field[.](#9.5.1.sentence-1)
Otherwise, MK is a non-static data member whose name is the identifier
determined by the character sequence encoded by NK in UTF-8[.](#9.5.1.sentence-2)
* [(9.5.2)](#9.5.2)
The type of MK is TK[.](#9.5.2.sentence-1)
* [(9.5.3)](#9.5.3)
MK is declared with the attribute [[no_unique_address]] if and only if NUAK is true[.](#9.5.3.sentence-1)
* [(9.5.4)](#9.5.4)
If WK is not ⊥, MK is a bit-field whose width is that value[.](#9.5.4.sentence-1)
Otherwise, MK is not a bit-field[.](#9.5.4.sentence-2)
* [(9.5.5)](#9.5.5)
If AK is not ⊥, MK has the [*alignment-specifier*](dcl.attr.grammar#nt:alignment-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") alignas(AK)[.](#9.5.5.sentence-1)
Otherwise, MK has no [*alignment-specifier*](dcl.attr.grammar#nt:alignment-specifier "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")[.](#9.5.5.sentence-2)
- [(9.6)](#9.6)
For every rL in mdescrs such that K<L,
the declaration corresponding to rK precedes the declaration corresponding to rL[.](#9.6.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6562)
*Returns*: class_type[.](#10.sentence-1)

View File

@@ -0,0 +1,114 @@
[meta.reflection.exception]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#exception)
### 21.4.4 Class exception [meta.reflection.exception]
[🔗](#lib:exception)
namespace std::meta {class exception : public std::exception {private: optional<string> *what_*; // *exposition only* u8string *u8what_*; // *exposition only* info *from_*; // *exposition only* source_location *where_*; // *exposition only*public:consteval exception(u8string_view what, info from,
source_location where = source_location::current()) noexcept; consteval exception(string_view what, info from,
source_location where = source_location::current()) noexcept;
exception(const exception&) = default;
exception(exception&&) = default;
exception& operator=(const exception&) = default;
exception& operator=(exception&&) = default; constexpr const char* what() const noexcept override; consteval u8string_view u8what() const noexcept; consteval info from() const noexcept; consteval source_location where() const noexcept; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3467)
Reflection functions throw exceptions of type meta::exception to signal an error[.](#1.sentence-1)
meta::exception is a consteval-only type[.](#1.sentence-2)
[🔗](#lib:exception,constructor)
`consteval exception(u8string_view what, info from,
source_location where = source_location::current()) noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3478)
*Effects*: Initializes*u8what_* with what,*from_* with from, and*where_* with where[.](#2.sentence-1)
If what can be represented in the ordinary literal encoding,
initializes *what_* with what,
transcoded from UTF-8 to the ordinary literal encoding[.](#2.sentence-2)
Otherwise, *what_* is value-initialized[.](#2.sentence-3)
[🔗](#lib:exception,constructor_)
`consteval exception(string_view what, info from,
source_location where = source_location::current()) noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3496)
*Constant When*: what designates a sequence of characters
that can be encoded in UTF-8[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3501)
*Effects*: Initializes*what_* with what,*u8what_* with what transcoded from the ordinary literal encoding to UTF-8,*from_* with from and*where_* with where[.](#4.sentence-1)
[🔗](#lib:what,exception)
`constexpr const char* what() const noexcept override;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3517)
*Constant When*: *what_*.has_value() is true[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3521)
*Returns*: *what_*->c_str()[.](#6.sentence-1)
[🔗](#lib:u8what,exception)
`consteval u8string_view u8what() const noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3531)
*Returns*: *u8what_*[.](#7.sentence-1)
[🔗](#lib:from,exception)
`consteval info from() const noexcept;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3541)
*Returns*: *from_*[.](#8.sentence-1)
[🔗](#lib:where,exception)
`consteval source_location where() const noexcept;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3551)
*Returns*: *where_*[.](#9.sentence-1)

View File

@@ -0,0 +1,182 @@
[meta.reflection.extract]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#extract)
### 21.4.12 Value extraction [meta.reflection.extract]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5837)
The extract function template may be used
to extract a value out of a reflection when its type is known[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5841)
The following are defined for exposition only
to aid in the specification of extract[.](#2.sentence-1)
[🔗](#itemdecl:1)
`template<class T>
consteval T extract-ref(info r); // exposition only
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5851)
[*Note [1](#note-1)*:
T is a reference type[.](#3.sentence-1)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5856)
*Returns*: If r represents an object O,
then a reference to O[.](#4.sentence-1)
Otherwise, a reference to the object declared, or referred to,
by the variable represented by r[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5863)
*Throws*: meta::exception unless
- [(5.1)](#5.1)
r represents a variable or object of type U,
- [(5.2)](#5.2)
is_convertible_v<remove_reference_t<U>(*)[], remove_reference_t<T>(*)[]> is true,
and
[*Note [2](#note-2)*:
The intent is to allow only qualification conversion from U to T[.](#5.2.sentence-1)
— *end note*]
- [(5.3)](#5.3)
If r represents a variable,
then either that variable is usable in constant expressions
or its lifetime began within the core constant expression currently under evaluation[.](#5.sentence-1)
[🔗](#itemdecl:2)
`template<class T>
consteval T extract-member-or-function(info r); // exposition only
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5888)
*Returns*:
- [(6.1)](#6.1)
If T is a pointer type,
then a pointer value pointing to the function represented by r[.](#6.1.sentence-1)
- [(6.2)](#6.2)
Otherwise, a pointer-to-member value
designating the non-static data member or function represented by r[.](#6.2.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5899)
*Throws*: meta::exception unless
- [(7.1)](#7.1)
r represents a non-static data member with type X,
that is not a bit-field,
that is a direct member of class C, T and X C::* are similar types ([[conv.qual]](conv.qual "7.3.6Qualification conversions")), and is_convertible_v<X C::*, T> is true;
- [(7.2)](#7.2)
r represents an implicit object member function
with type F or F noexcept that is a direct member of a class C,
and T is F C::*; or
- [(7.3)](#7.3)
r represents a non-member function,
static member function, or
explicit object member function
of function type F or F noexcept,
and T is F*[.](#7.sentence-1)
[🔗](#itemdecl:3)
`template<class T>
consteval T extract-value(info r); // exposition only
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5929)
Let U be the type of the value or object that r represents[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5932)
*Returns*: static_cast<T>([:R:]),
where R is a constant expression of type info such that R == r is true[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5938)
*Throws*: meta::exception unless
- [(10.1)](#10.1)
U is a pointer type, T and U are either similar ([[conv.qual]](conv.qual "7.3.6Qualification conversions"))
or both function pointer types, and is_convertible_v<U, T> is true,
- [(10.2)](#10.2)
U is not a pointer type
and the cv-unqualified types of T and U are the same,
- [(10.3)](#10.3)
U is an array type, T is a pointer type, and
the value r represents is convertible to T, or
- [(10.4)](#10.4)
U is a closure type, T is a function pointer type, and
the value that r represents is convertible to T[.](#10.sentence-1)
[🔗](#lib:extract)
`template<class T>
consteval T extract(info r);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5968)
Let U be remove_cv_t<T>[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5971)
*Effects*: Equivalent to:if constexpr (is_reference_type(^^T)) {return *extract-ref*<T>(r);} else if constexpr (is_nonstatic_data_member(r) || is_function(r)) {return *extract-member-or-function*<U>(r);} else {return *extract-value*<U>(constant_of(r));}

View File

@@ -0,0 +1,229 @@
[meta.reflection.layout]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#layout)
### 21.4.11 Reflection layout queries [meta.reflection.layout]
[🔗](#lib:member_offset)
`struct member_offset {
ptrdiff_t bytes;
ptrdiff_t bits;
constexpr ptrdiff_t total_bits() const;
auto operator<=>(const member_offset&) const = default;
};
constexpr ptrdiff_t member_offset::total_bits() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5663)
*Returns*: bytes * CHAR_BIT + bits[.](#1.sentence-1)
[🔗](#lib:offset_of)
`consteval member_offset offset_of(info r);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5674)
Let V be the offset in bits from the beginning of a complete object
of the type represented by parent_of(r) to the subobject associated with the entity represented by r[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5679)
*Returns*: {V / CHAR_BIT, V % CHAR_BIT}[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5683)
*Throws*: meta::exception unlessr represents a non-static data member,
unnamed bit-field, or
direct base class relationship (D,B) for which either B is not a virtual base class
or D is not an abstract class[.](#4.sentence-1)
[🔗](#lib:size_of)
`consteval size_t size_of(info r);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5699)
*Returns*: If r represents
- [(5.1)](#5.1)
a non-static data member of type T,
- [(5.2)](#5.2)
a data member description (T,N,A,W,NUA), or
- [(5.3)](#5.3)
dealias(r) represents a type T,
then sizeof(T) if T is not a reference type
and size_of(add_pointer(^^T)) otherwise[.](#5.sentence-1)
Otherwise, size_of(type_of(r))[.](#5.sentence-2)
[*Note [1](#note-1)*:
It is possible that while sizeof(char) == size_of(^^char) is true,
that sizeof(char&) == size_of(^^char&) is false[.](#5.sentence-3)
If b represents a direct base class relationship of an empty base class,
then size_of(b) > 0 is true[.](#5.sentence-4)
— *end note*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5719)
*Throws*: meta::exception unless
all of the following conditions are met:
- [(6.1)](#6.1)
dealias(r) is a reflection of a
type,
object,
value,
variable of non-reference type,
non-static data member that is not a bit-field,
direct base class relationship, or
data member description (T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General"))
where W is not ⊥[.](#6.1.sentence-1)
- [(6.2)](#6.2)
If dealias(r) represents a type,
then is_complete_type(r) is true[.](#6.2.sentence-1)
[🔗](#lib:alignment_of)
`consteval size_t alignment_of(info r);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5746)
*Returns*:
- [(7.1)](#7.1)
If dealias(r) represents a type T,
then alignment_of(add_pointer(r)) if T is a reference type
and the alignment requirement of T otherwise[.](#7.1.sentence-1)
- [(7.2)](#7.2)
Otherwise, if dealias(r) represents a variable or object,
then the alignment requirement of the variable or object[.](#7.2.sentence-1)
- [(7.3)](#7.3)
Otherwise, if r represents a direct base class relationship,
then alignment_of(type_of(r))[.](#7.3.sentence-1)
- [(7.4)](#7.4)
Otherwise, if r represents a non-static data member M of a class C,
then the alignment of the direct member subobject
corresponding to M of a complete object of type C[.](#7.4.sentence-1)
- [(7.5)](#7.5)
Otherwise, r represents a data member description (T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General"))[.](#7.5.sentence-1)
If A is not ⊥,
then the value A[.](#7.5.sentence-2)
Otherwise, alignment_of(^^T)[.](#7.5.sentence-3)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5771)
*Throws*: meta::exception unless
all of the following conditions are met:
- [(8.1)](#8.1)
dealias(r) is a reflection of a
type,
object,
variable of non-reference type,
non-static data member that is not a bit-field,
direct base class relationship, or
data member description[.](#8.1.sentence-1)
- [(8.2)](#8.2)
If dealias(r) represents a type,
then is_complete_type(r) is true[.](#8.2.sentence-1)
[🔗](#lib:bit_size_of)
`consteval size_t bit_size_of(info r);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5796)
*Returns*:
- [(9.1)](#9.1)
If r represents
an unnamed bit-field
or a non-static data member that is a bit-field
with width W,
then W[.](#9.1.sentence-1)
- [(9.2)](#9.2)
Otherwise, if r represents a data member description (T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General"))
and W is not ⊥,
then W[.](#9.2.sentence-1)
- [(9.3)](#9.3)
Otherwise, CHAR_BIT * size_of(r)[.](#9.3.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5814)
*Throws*: meta::exception unless
all of the following conditions are met:
- [(10.1)](#10.1)
dealias(r) is a reflection of a
type,
object,
value,
variable of non-reference type,
non-static data member,
unnamed bit-field,
direct base class relationship, or
data member description[.](#10.1.sentence-1)
- [(10.2)](#10.2)
If dealias(r) represents a type T,
there is a point within the evaluation context from which T is not incomplete[.](#10.2.sentence-1)

View File

@@ -0,0 +1,268 @@
[meta.reflection.member.queries]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#member.queries)
### 21.4.10 Reflection member queries [meta.reflection.member.queries]
[🔗](#lib:members_of)
`consteval vector<info> members_of(info r, access_context ctx);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5407)
A declaration D [*members-of-precedes*](#def:members-of-precedes) a point P if D precedes either P or the point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1Preamble[class.pre]") of the outermost class for which P is in a complete-class context[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5413)
A declaration D of a member M of a class or namespace Q is[*Q-members-of-eligible*](#def:Q-members-of-eligible) if
- [(2.1)](#2.1)
the host scope of D ([[basic.scope.scope]](basic.scope.scope "6.4.1General"))
is the class scope or namespace scope associated with Q,
- [(2.2)](#2.2)
D is not a friend declaration,
- [(2.3)](#2.3)
M is not a closure type ([[expr.prim.lambda.closure]](expr.prim.lambda.closure "7.5.6.2Closure types")),
- [(2.4)](#2.4)
M is not a specialization of a template ([[temp.pre]](temp.pre "13.1Preamble")),
- [(2.5)](#2.5)
if Q is a class that is not a closure type,
then M is a direct member of Q ([[class.mem.general]](class.mem.general "11.4.1General"))
that is not a variant member of a
nested anonymous union of Q ([[class.union.anon]](class.union.anon "11.5.2Anonymous unions")), and
- [(2.6)](#2.6)
if Q is a closure type,
then M is a function call operator or function call operator template[.](#2.sentence-1)
It is implementation-defined
whether declarations of other members of a closure type Q are Q-members-of-eligible[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5440)
A member M of a class or namespace Q is[*Q-members-of-representable*](#def:Q-members-of-representable) from a point P if a Q-members-of-eligible declaration of M members-of-precedes P,
and M is
- [(3.1)](#3.1)
a class or enumeration type
- [(3.2)](#3.2)
a type alias
- [(3.3)](#3.3)
a class template, function template,
variable template, alias template, or concept,
- [(3.4)](#3.4)
a variable or reference V for which the type of V does not contain an undeduced placeholder type,
- [(3.5)](#3.5)
a function F for which
* [(3.5.1)](#3.5.1)
the type of F does not contain an undeduced placeholder type,
* [(3.5.2)](#3.5.2)
the constraints (if any) of F are satisfied, and
* [(3.5.3)](#3.5.3)
if F is a prospective destructor, F is the selected destructor ([[class.dtor]](class.dtor "11.4.7Destructors")),
- [(3.6)](#3.6)
a non-static data member,
- [(3.7)](#3.7)
a namespace, or
- [(3.8)](#3.8)
a namespace alias[.](#3.sentence-1)
[*Note [1](#note-1)*:
Examples of direct members that are not Q-members-of-representable
for any entity Q include:
unscoped enumerators ([[enum]](enum "9.8Enumerations")),
partial specializations of templates ([[temp.spec.partial]](temp.spec.partial "13.7.6Partial specialization")), and
closure types ([[expr.prim.lambda.closure]](expr.prim.lambda.closure "7.5.6.2Closure types"))[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5482)
*Returns*: A vector containing reflections of all members M of the entity Q represented by dealias(r) for which
- [(4.1)](#4.1)
M is Q-members-of-representable
from some point in the evaluation context and
- [(4.2)](#4.2)
is_accessible(^^M, ctx) is true[.](#4.sentence-1)
If dealias(r) represents a class C,
then the vector also contains reflections
representing all unnamed bit-fields B whose declarations inhabit the class scope corresponding to C for which is_accessible(^^B, ctx) is true[.](#4.sentence-2)
Reflections of class members and unnamed bit-fields that are declared
appear in the order in which they are declared[.](#4.sentence-3)
[*Note [2](#note-2)*:
Base classes are not members[.](#4.sentence-4)
Implicitly-declared special members
appear after any user-declared members ([[special]](special "11.4.4Special member functions"))[.](#4.sentence-5)
— *end note*]
[*Example [1](#example-1)*: // TU1export module M;namespace NS {export int m; static int l;}static_assert(members_of(^^NS, access_context::current()).size() == 2);
// TU2import M;
static_assert( // NS::l does not precede members_of(^^NS, access_context::current()).size() == 1); // the constant-expression ([[basic.lookup]](basic.lookup "6.5Name lookup"))class B {};
struct S : B {private:class I;public:int m;};
static_assert( // 6 special members, members_of(^^S, access_context::current()).size() == 7); // 1 public member,// does not include basestatic_assert( // all of the above, members_of(^^S, access_context::unchecked()).size() == 8); // as well as a reflection// representing S::I — *end example*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5540)
*Throws*: meta::exception unlessdealias(r) is a reflection representing either
a class type that is complete from some point in the evaluation context
or a namespace[.](#5.sentence-1)
[🔗](#lib:bases_of)
`consteval vector<info> bases_of(info type, access_context ctx);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5554)
*Returns*: Let C be the class represented by dealias(type)[.](#6.sentence-1)
A vector containing the reflections
of all the direct base class relationships B, if any,
of C such that is_accessible(^^B, ctx) is true[.](#6.sentence-2)
The direct base class relationships appear in the order in which
the corresponding base classes appear in the [*base-specifier-list*](class.derived.general#nt:base-specifier-list "11.7.1General[class.derived.general]") of C[.](#6.sentence-3)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5563)
*Throws*: meta::exception unlessdealias(type) represents a class type
that is complete from some point in the evaluation context[.](#7.sentence-1)
[🔗](#lib:static_data_members_of)
`consteval vector<info> static_data_members_of(info type, access_context ctx);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5576)
*Returns*: A vector containing each element e of members_of(type, ctx) such that is_variable(e) is true,
preserving their order[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5582)
*Throws*: meta::exception unlessdealias(type) represents a class type
that is complete from some point in the evaluation context[.](#9.sentence-1)
[🔗](#lib:nonstatic_data_members_of)
`consteval vector<info> nonstatic_data_members_of(info type, access_context ctx);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5596)
*Returns*: A vector containing each element e of members_of(type, ctx) such that is_nonstatic_data_member(e) is true,
preserving their order[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5602)
*Throws*: meta::exception unlessdealias(type) represents a class type
that is complete from some point in the evaluation context[.](#11.sentence-1)
[🔗](#lib:subobjects_of)
`consteval vector<info> subobjects_of(info type, access_context ctx);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5615)
*Returns*: A vector containing each element of bases_of(type, ctx) followed by each element of nonstatic_data_members_of(type, ctx),
preserving their order[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5621)
*Throws*: meta::exception unlessdealias(type) represents a class type
that is complete from some point in the evaluation context[.](#13.sentence-1)
[🔗](#lib:enumerators_of)
`consteval vector<info> enumerators_of(info type_enum);
`
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5634)
*Returns*: A vector containing the reflections of each enumerator
of the enumeration represented by dealias(type_enum),
in the order in which they are declared[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5640)
*Throws*: meta::exception unlessdealias(type_enum) represents an enumeration type,
and is_enumerable_type(type_enum) is true[.](#15.sentence-1)

View File

@@ -0,0 +1,230 @@
[meta.reflection.names]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#names)
### 21.4.6 Reflection names and locations [meta.reflection.names]
[🔗](#lib:has_identifier)
`consteval bool has_identifier(info r);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3673)
*Returns*:
- [(1.1)](#1.1)
If r represents an entity
that has a typedef name for linkage purposes ([[dcl.typedef]](dcl.typedef "9.2.4The typedef specifier")),
then true[.](#1.1.sentence-1)
- [(1.2)](#1.2)
Otherwise, if r represents an unnamed entity,
then false[.](#1.2.sentence-1)
- [(1.3)](#1.3)
Otherwise, if r represents a class type,
then !has_template_arguments(r)[.](#1.3.sentence-1)
- [(1.4)](#1.4)
Otherwise, if r represents a function,
then true if has_template_arguments(r) is false and the function is not a
constructor,
destructor,
operator function, or
conversion function[.](#1.4.sentence-1)
Otherwise, false[.](#1.4.sentence-2)
- [(1.5)](#1.5)
Otherwise, if r represents a template,
then true if r does not represent a
constructor template,
operator function template,
or conversion function template[.](#1.5.sentence-1)
Otherwise, false[.](#1.5.sentence-2)
- [(1.6)](#1.6)
Otherwise, if r represents the ith parameter of a function F that is an (implicit or explicit) specialization of a templated function T and the ith parameter of the instantiated declaration of T whose template arguments are those of F would be instantiated from a pack,
then false[.](#1.6.sentence-1)
- [(1.7)](#1.7)
Otherwise, if r represents the parameter P of a function F,
then let S be the set of declarations,
ignoring any explicit instantiations,
that precede some point in the evaluation context
and that declare either F or a templated function
of which F is a specialization; true if
* [(1.7.1)](#1.7.1)
there is a declaration D in S that introduces a name N for either P or the parameter corresponding to P in the templated function that D declares and
* [(1.7.2)](#1.7.2)
no declaration in S does so using any name other than N[.](#1.7.sentence-1)
Otherwise, false[.](#1.7.sentence-2)
[*Example [1](#example-1)*: void fun(int);constexpr std::meta::info r = parameters_of(^^fun)[0];static_assert(!has_identifier(r));
void fun(int x);static_assert(has_identifier(r));
void fun(int x);static_assert(has_identifier(r));
void poison() {void fun(int y);}static_assert(!has_identifier(r)); — *end example*]
- [(1.8)](#1.8)
Otherwise, if r represents a variable,
then false if the declaration of that variable
was instantiated from a function parameter pack[.](#1.8.sentence-1)
Otherwise, !has_template_arguments(r)[.](#1.8.sentence-2)
- [(1.9)](#1.9)
Otherwise, if r represents a structured binding,
then false if the declaration of that structured binding
was instantiated from a structured binding pack[.](#1.9.sentence-1)
Otherwise, true[.](#1.9.sentence-2)
- [(1.10)](#1.10)
Otherwise, if r represents a type alias,
then !has_template_arguments(r)[.](#1.10.sentence-1)
- [(1.11)](#1.11)
Otherwise, if r represents an
enumerator,
non-static-data member,
namespace, or
namespace alias,
then true[.](#1.11.sentence-1)
- [(1.12)](#1.12)
Otherwise, if r represents a direct base class relationship,
then has_identifier(type_of(r))[.](#1.12.sentence-1)
- [(1.13)](#1.13)
Otherwise, r represents a data member description (T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General")); true if N is not ⊥[.](#1.13.sentence-1)
Otherwise, false[.](#1.13.sentence-2)
[🔗](#lib:identifier_of)
`consteval string_view identifier_of(info r);
consteval u8string_view u8identifier_of(info r);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3782)
Let E be UTF-8 for u8identifier_of,
and otherwise the ordinary literal encoding[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3786)
*Returns*: An ntmbs, encoded with E,
determined as follows:
- [(3.1)](#3.1)
If r represents an entity with a typedef name for linkage purposes,
then that name[.](#3.1.sentence-1)
- [(3.2)](#3.2)
Otherwise, if r represents a literal operator or literal operator template,
then the [*ud-suffix*](lex.ext#nt:ud-suffix "5.13.9User-defined literals[lex.ext]") of the operator or operator template[.](#3.2.sentence-1)
- [(3.3)](#3.3)
Otherwise, if r represents the parameter P of a function F,
then let S be the set of declarations,
ignoring any explicit instantiations,
that precede some point in the evaluation context
and that declare either F or a templated function of which F is a specialization;
the name that was introduced by a declaration in S for the parameter corresponding to P[.](#3.3.sentence-1)
- [(3.4)](#3.4)
Otherwise, if r represents an entity,
then the identifier introduced by the declaration of that entity[.](#3.4.sentence-1)
- [(3.5)](#3.5)
Otherwise, if r represents a direct base class relationship,
then identifier_of(type_of(r)) or u8identifier_of(type_of(r)),
respectively[.](#3.5.sentence-1)
- [(3.6)](#3.6)
Otherwise, r represents a data member description (T,N,A,W,NUA) ([[class.mem.general]](class.mem.general "11.4.1General"));
a string_view or u8string_view, respectively,
containing the identifier N[.](#3.6.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3820)
*Throws*: meta::exception unlesshas_identifier(r) is true and the identifier that would be returned (see above)
is representable by E[.](#4.sentence-1)
[🔗](#lib:display_string_of)
`consteval string_view display_string_of(info r);
consteval u8string_view u8display_string_of(info r);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3836)
*Returns*: Animplementation-definedstring_view or u8string_view, respectively[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3842)
*Recommended practice*: Where possible,
implementations should return a string
suitable for identifying the represented construct[.](#6.sentence-1)
[🔗](#lib:source_location_of)
`consteval source_location source_location_of(info r);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3855)
*Returns*: If r represents
a value,
a type other than a class type or an enumeration type,
the global namespace, or
a data member description,
then source_location{}[.](#7.sentence-1)
Otherwise, animplementation-definedsource_location value[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L3867)
*Recommended practice*: If r represents an entity with a definition
that is reachable from the evaluation context,
a value corresponding to a definition should be returned[.](#8.sentence-1)

View File

@@ -0,0 +1,111 @@
[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)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,121 @@
[meta.reflection.result]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#result)
### 21.4.14 Expression result reflection [meta.reflection.result]
[🔗](#lib:reflect_constant)
`template<class T>
consteval info reflect_constant(T expr);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6097)
*Mandates*: is_copy_constructible_v<T> is true and T is a cv-unqualified structural type ([[temp.param]](temp.param "13.2Template parameters"))
that is not a reference type[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6103)
Let V be:
- [(2.1)](#2.1)
if T is a class type,
then an object that is template-argument-equivalent to the value of expr;
- [(2.2)](#2.2)
otherwise, the value of expr[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6113)
*Returns*: template_arguments_of(^^TCls<V>)[0],
with TCls as defined below[.](#3.sentence-1)
[*Note [1](#note-1)*:
This is a reflection of an object for class types,
and a reflection of a value otherwise[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6122)
*Throws*: meta::exception unless
the [*template-id*](temp.names#nt:template-id "13.3Names of template specializations[temp.names]") TCls<V> would be valid
given the invented templatetemplate<T P> struct TCls;
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6131)
[*Example [1](#example-1)*: template<auto D>struct A { };
struct N { int x; };struct K { char const* p; };
constexpr info r1 = reflect_constant(42);static_assert(is_value(r1));static_assert(r1 == template_arguments_of(^^A<42>)[0]);
constexpr info r2 = reflect_constant(N{42});static_assert(is_object(r2));static_assert(r2 == template_arguments_of(^^A<N{42}>)[0]);
constexpr info r3 = reflect_constant(K{nullptr}); // OKconstexpr info r4 = reflect_constant(K{"ebab"}); // error: constituent pointer// points to string literal — *end example*]
[🔗](#lib:reflect_object)
`template<class T>
consteval info reflect_object(T& expr);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6162)
*Mandates*: T is an object type[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6166)
*Returns*: A reflection of the object designated by expr[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6170)
*Throws*: meta::exception unlessexpr is suitable for use as a constant template argument
for a constant template parameter of type T& ([[temp.arg.nontype]](temp.arg.nontype "13.4.3Constant template arguments"))[.](#8.sentence-1)
[🔗](#lib:reflect_function)
`template<class T>
consteval info reflect_function(T& fn);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6184)
*Mandates*: T is a function type[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6188)
*Returns*: A reflection of the function designated by fn[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6192)
*Throws*: meta::exception unlessfn is suitable for use as a constant template argument
for a constant template parameter of type T& ([[temp.arg.nontype]](temp.arg.nontype "13.4.3Constant template arguments"))[.](#11.sentence-1)

View File

@@ -0,0 +1,108 @@
[meta.reflection.substitute]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#substitute)
### 21.4.13 Reflection substitution [meta.reflection.substitute]
[🔗](#concept:reflection_range)
`template<class R>
concept [reflection_range](#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") =
ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]")<R> &&
[same_as](concept.same#concept:same_as "18.4.2Concept same_­as[concept.same]")<ranges::range_value_t<R>, info> &&
[same_as](concept.same#concept:same_as "18.4.2Concept same_­as[concept.same]")<remove_cvref_t<ranges::range_reference_t<R>>, info>;
template<[reflection_range](#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>
consteval bool [can_substitute](#lib:can_substitute "21.4.13Reflection substitution[meta.reflection.substitute]")(info templ, R&& arguments);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L5999)
Let Z be the template represented by templ and let Args... be a sequence of prvalue constant expressions
that compute the reflections held by the elements of arguments,
in order[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6005)
*Returns*: true if Z<[:Args:]...> is a valid [*template-id*](temp.names#nt:template-id "13.3Names of template specializations[temp.names]") ([[temp.names]](temp.names "13.3Names of template specializations"))
that does not name a function
whose type contains an undeduced placeholder type[.](#2.sentence-1)
Otherwise, false[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6012)
*Throws*: meta::exception unlesstempl represents a template,
and every reflection in arguments represents a construct
usable as a template argument ([[temp.arg]](temp.arg "13.4Template arguments"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6019)
[*Note [1](#note-1)*:
If forming Z<[:Args:]...> leads to a failure
outside of the immediate context,
the program is ill-formed[.](#4.sentence-1)
— *end note*]
[🔗](#lib:substitute)
`template<[reflection_range](#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>
consteval info substitute(info templ, R&& arguments);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6034)
Let Z be the template represented by templ and let Args... be a sequence of prvalue constant expressions
that compute the reflections held by the elements of arguments,
in order[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6040)
*Returns*: ^^Z<[:Args:]...>[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6044)
*Throws*: meta::exception unlesscan_substitute(templ, arguments) is true[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6049)
[*Note [2](#note-2)*:
If forming Z<[:Args:]...> leads to a failure outside of the immediate context,
the program is ill-formed[.](#8.sentence-1)
— *end note*]
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6055)
[*Example [1](#example-1)*: template<class T>auto fn1();
static_assert(!can_substitute(^^fn1, {^^int})); // OKconstexpr info r1 = substitute(^^fn1, {^^int}); // error: fn<int> contains an undeduced// placeholder type for its return typetemplate<class T>auto fn2() {static_assert(^^T != ^^int); // static assertion failed during instantiation of fn<int>return 0; }constexpr bool r2 = can_substitute(^^fn2, {^^int}); // error: instantiation of body of fn<int>// is needed to deduce return type — *end example*]
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6076)
[*Example [2](#example-2)*: consteval info to_integral_constant(unsigned i) {return substitute(^^integral_constant, {^^unsigned, reflect_constant(i)});}constexpr info r = to_integral_constant(2); // OK, r represents the type// integral_constant<unsigned, 2> — *end example*]

View File

@@ -0,0 +1,222 @@
[meta.reflection.traits]
# 21 Metaprogramming library [[meta]](./#meta)
## 21.4 Reflection [[meta.reflection]](meta.reflection#traits)
### 21.4.17 Reflection type traits [meta.reflection.traits]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6569)
This subclause specifies consteval functions to
query the properties of types ([[meta.unary]](meta.unary "21.3.6Unary type traits")),
query the relationships between types ([[meta.rel]](meta.rel "21.3.8Relationships between types")), or
transform types ([[meta.trans]](meta.trans "21.3.9Transformations between types")),
during program translation[.](#1.sentence-1)
Each consteval function declared in this class
has an associated class template declared elsewhere in this document[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6578)
Every function and function template declared in this subclause
throws an exception of type meta::exception unless the following conditions are met:
- [(2.1)](#2.1)
For every parameter p of type info, is_type(p) is true[.](#2.1.sentence-1)
- [(2.2)](#2.2)
For every parameter r whose type is constrained on [reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]"), ranges::all_of(r, is_type) is true[.](#2.2.sentence-1)
// associated with [[meta.unary.cat]](meta.unary.cat "21.3.6.2Primary type categories"), primary type categoriesconsteval bool [is_void_type](#lib:is_void_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_null_pointer_type](#lib:is_null_pointer_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_integral_type](#lib:is_integral_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_floating_point_type](#lib:is_floating_point_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_array_type](#lib:is_array_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_pointer_type](#lib:is_pointer_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_lvalue_reference_type](#lib:is_lvalue_reference_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_rvalue_reference_type](#lib:is_rvalue_reference_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_member_object_pointer_type](#lib:is_member_object_pointer_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_member_function_pointer_type](#lib:is_member_function_pointer_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_enum_type](#lib:is_enum_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_union_type](#lib:is_union_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_class_type](#lib:is_class_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_function_type](#lib:is_function_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_reflection_type](#lib:is_reflection_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.unary.comp]](meta.unary.comp "21.3.6.3Composite type traits"), composite type categoriesconsteval bool [is_reference_type](#lib:is_reference_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_arithmetic_type](#lib:is_arithmetic_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_fundamental_type](#lib:is_fundamental_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_object_type](#lib:is_object_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_scalar_type](#lib:is_scalar_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_compound_type](#lib:is_compound_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_member_pointer_type](#lib:is_member_pointer_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.unary.prop]](meta.unary.prop "21.3.6.4Type properties"), type propertiesconsteval bool [is_const_type](#lib:is_const_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_volatile_type](#lib:is_volatile_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_copyable_type](#lib:is_trivially_copyable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_relocatable_type](#lib:is_trivially_relocatable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_replaceable_type](#lib:is_replaceable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_standard_layout_type](#lib:is_standard_layout_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_empty_type](#lib:is_empty_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_polymorphic_type](#lib:is_polymorphic_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_abstract_type](#lib:is_abstract_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_final_type](#lib:is_final_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_aggregate_type](#lib:is_aggregate_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_consteval_only_type](#lib:is_consteval_only_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_signed_type](#lib:is_signed_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_unsigned_type](#lib:is_unsigned_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_bounded_array_type](#lib:is_bounded_array_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_unbounded_array_type](#lib:is_unbounded_array_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_scoped_enum_type](#lib:is_scoped_enum_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_constructible_type](#lib:is_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);consteval bool [is_default_constructible_type](#lib:is_default_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_copy_constructible_type](#lib:is_copy_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_move_constructible_type](#lib:is_move_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_assignable_type](#lib:is_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_dst, info type_src);consteval bool [is_copy_assignable_type](#lib:is_copy_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_move_assignable_type](#lib:is_move_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_swappable_with_type](#lib:is_swappable_with_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type1, info type2);consteval bool [is_swappable_type](#lib:is_swappable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_destructible_type](#lib:is_destructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_trivially_constructible_type](#lib:is_trivially_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);consteval bool [is_trivially_default_constructible_type](#lib:is_trivially_default_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_copy_constructible_type](#lib:is_trivially_copy_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_move_constructible_type](#lib:is_trivially_move_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_trivially_assignable_type](#lib:is_trivially_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_dst, info type_src);consteval bool [is_trivially_copy_assignable_type](#lib:is_trivially_copy_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_move_assignable_type](#lib:is_trivially_move_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_trivially_destructible_type](#lib:is_trivially_destructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_nothrow_constructible_type](#lib:is_nothrow_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);consteval bool [is_nothrow_default_constructible_type](#lib:is_nothrow_default_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_nothrow_copy_constructible_type](#lib:is_nothrow_copy_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_nothrow_move_constructible_type](#lib:is_nothrow_move_constructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_nothrow_assignable_type](#lib:is_nothrow_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_dst, info type_src);consteval bool [is_nothrow_copy_assignable_type](#lib:is_nothrow_copy_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_nothrow_move_assignable_type](#lib:is_nothrow_move_assignable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_nothrow_swappable_with_type](#lib:is_nothrow_swappable_with_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type1, info type2);consteval bool [is_nothrow_swappable_type](#lib:is_nothrow_swappable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_nothrow_destructible_type](#lib:is_nothrow_destructible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval bool [is_nothrow_relocatable_type](#lib:is_nothrow_relocatable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [is_implicit_lifetime_type](#lib:is_implicit_lifetime_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [has_virtual_destructor](#lib:has_virtual_destructor "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [has_unique_object_representations](#lib:has_unique_object_representations "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
consteval bool [reference_constructs_from_temporary](#lib:reference_constructs_from_temporary "21.4.17Reflection type traits[meta.reflection.traits]")(info type_dst, info type_src);consteval bool [reference_converts_from_temporary](#lib:reference_converts_from_temporary "21.4.17Reflection type traits[meta.reflection.traits]")(info type_dst, info type_src);
// associated with [[meta.rel]](meta.rel "21.3.8Relationships between types"), type relationsconsteval bool [is_same_type](#lib:is_same_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type1, info type2);consteval bool [is_base_of_type](#lib:is_base_of_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_base, info type_derived);consteval bool [is_virtual_base_of_type](#lib:is_virtual_base_of_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_base, info type_derived);consteval bool [is_convertible_type](#lib:is_convertible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_src, info type_dst);consteval bool [is_nothrow_convertible_type](#lib:is_nothrow_convertible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_src, info type_dst);consteval bool [is_layout_compatible_type](#lib:is_layout_compatible_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type1, info type2);consteval bool [is_pointer_interconvertible_base_of_type](#lib:is_pointer_interconvertible_base_of_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_base, info type_derived);
template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_invocable_type](#lib:is_invocable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_invocable_r_type](#lib:is_invocable_r_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_result, info type, R&& type_args);
template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_nothrow_invocable_type](#lib:is_nothrow_invocable_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval bool [is_nothrow_invocable_r_type](#lib:is_nothrow_invocable_r_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type_result, info type, R&& type_args);
// associated with [[meta.trans.cv]](meta.trans.cv "21.3.9.2Const-volatile modifications"), const-volatile modificationsconsteval info [remove_const](#lib:remove_const "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [remove_volatile](#lib:remove_volatile "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [remove_cv](#lib:remove_cv "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_const](#lib:add_const "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_volatile](#lib:add_volatile "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_cv](#lib:add_cv "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.trans.ref]](meta.trans.ref "21.3.9.3Reference modifications"), reference modificationsconsteval info [remove_reference](#lib:remove_reference "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_lvalue_reference](#lib:add_lvalue_reference "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_rvalue_reference](#lib:add_rvalue_reference "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.trans.sign]](meta.trans.sign "21.3.9.4Sign modifications"), sign modificationsconsteval info [make_signed](#lib:make_signed "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [make_unsigned](#lib:make_unsigned "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.trans.arr]](meta.trans.arr "21.3.9.5Array modifications"), array modificationsconsteval info [remove_extent](#lib:remove_extent "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [remove_all_extents](#lib:remove_all_extents "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.trans.ptr]](meta.trans.ptr "21.3.9.6Pointer modifications"), pointer modificationsconsteval info [remove_pointer](#lib:remove_pointer "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [add_pointer](#lib:add_pointer "21.4.17Reflection type traits[meta.reflection.traits]")(info type);
// associated with [[meta.trans.other]](meta.trans.other "21.3.9.7Other transformations"), other transformationsconsteval info [remove_cvref](#lib:remove_cvref "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [decay](#lib:decay "21.4.17Reflection type traits[meta.reflection.traits]")(info type);template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval info [common_type](time.traits.specializations#lib:common_type "30.4.3Specializations of common_­type[time.traits.specializations]")(R&& type_args);template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval info [common_reference](#lib:common_reference "21.4.17Reflection type traits[meta.reflection.traits]")(R&& type_args);consteval info [underlying_type](#lib:underlying_type "21.4.17Reflection type traits[meta.reflection.traits]")(info type);template<[reflection_range](meta.reflection.substitute#concept:reflection_range "21.4.13Reflection substitution[meta.reflection.substitute]") R = initializer_list<info>>consteval info [invoke_result](#lib:invoke_result "21.4.17Reflection type traits[meta.reflection.traits]")(info type, R&& type_args);consteval info [unwrap_reference](#lib:unwrap_reference "21.4.17Reflection type traits[meta.reflection.traits]")(info type);consteval info [unwrap_ref_decay](functional.syn#lib:unwrap_ref_decay "22.10.2Header <functional> synopsis[functional.syn]")(info type);
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6747)
Each function or function template declared above has the following behavior
based on the signature and return type of that function or function template[.](#3.sentence-1)
[*Note [1](#note-1)*:
The associated class template need not be instantiated[.](#3.sentence-2)
— *end note*]
Table [64](#tab:meta.reflection.traits) — Reflection type traits [[tab:meta.reflection.traits]](./tab:meta.reflection.traits)
| [🔗](#tab:meta.reflection.traits-row-1)<br>**Signature and Return Type** | ***Returns*** |
| --- | --- |
| [🔗](#tab:meta.reflection.traits-row-2)<br>bool meta::*UNARY*(info type); bool meta::*UNARY*_type(info type); | std::*UNARY*_v<T>, where T is the type or type alias represented by type |
| [🔗](#tab:meta.reflection.traits-row-3)<br>bool meta::*BINARY*(info t1, info t2); bool meta::*BINARY*_type(info t1, info t2); | std::*BINARY*_v<T1, T2>, where T1 and T2 are the types or type aliases represented by t1 and t2, respectively |
| [🔗](#tab:meta.reflection.traits-row-4)<br>template<reflection_range R> bool meta::*VARIADIC*_type(info type, R&& args); | std::*VARIADIC*_v<T, U...>, where T is the type or type alias represented by type and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args |
| [🔗](#tab:meta.reflection.traits-row-5)<br>template<reflection_range R> bool meta::*VARIADIC*_type(info t1, info t2, R&& args); | std::*VARIADIC*_v<T1, T2, U...>, where T1 and T2 are the types or type aliases represented by t1 and t2, respectively, and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args |
| [🔗](#tab:meta.reflection.traits-row-6)<br>info meta::*UNARY*(info type); | A reflection representing the type denoted by std::*UNARY*_t<T>, where T is the type or type alias represented by type |
| [🔗](#tab:meta.reflection.traits-row-7)<br>template<reflection_range R> info meta::*VARIADIC*(R&& args); | A reflection representing the type denoted by std::*VARIADIC*_t<T...>, where T... is the pack of types or type aliases whose elements are represented by the corresponding elements of args |
| [🔗](#tab:meta.reflection.traits-row-8)<br>template<reflection_range R> info meta::*VARIADIC*(info type, R&& args); | A reflection representing the type denoted by std::*VARIADIC*_t<T, U...>, where T is the type or type alias represented by type and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args |
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6817)
[*Note [2](#note-2)*:
For those functions or function templates which return a reflection,
that reflection always represents a type and never a type alias[.](#4.sentence-1)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6823)
[*Note [3](#note-3)*:
If t is a reflection of the type int and u is a reflection of an alias to the type int,
then t == u is false but is_same_type(t, u) is true[.](#5.sentence-1)
Also, t == dealias(u) is true[.](#5.sentence-2)
— *end note*]
[🔗](#lib:rank)
`consteval size_t rank(info type);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6838)
*Returns*: rank_v<T>,
where T is the type represented by dealias(type)[.](#6.sentence-1)
[🔗](#lib:extent)
`consteval size_t extent(info type, unsigned i = 0);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6850)
*Returns*: extent_v<T, I>,
where T is the type represented by dealias(type) and I is a constant equal to i[.](#7.sentence-1)
[🔗](#lib:tuple_size)
`consteval size_t tuple_size(info type);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6863)
*Returns*: tuple_size_v<T>,
where T is the type represented by dealias(type)[.](#8.sentence-1)
[🔗](#lib:tuple_element)
`consteval info tuple_element(size_t index, info type);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6875)
*Returns*: A reflection representing
the type denoted by tuple_element_t<I, T>,
where T is the type represented by dealias(type) and I is a constant equal to index[.](#9.sentence-1)
[🔗](#lib:variant_size)
`consteval size_t variant_size(info type);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6889)
*Returns*: variant_size_v<T>,
where T is the type represented by dealias(type)[.](#10.sentence-1)
[🔗](#lib:variant_alternative)
`consteval info variant_alternative(size_t index, info type);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6901)
*Returns*: A reflection representing the type denoted byvariant_alternative_t<I, T>,
where T is the type represented by dealias(type) and I is a constant equal to index[.](#11.sentence-1)
[🔗](#lib:type_order)
`consteval strong_ordering type_order(info t1, info t2);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/meta.tex#L6915)
*Returns*: type_order_v<T1, T2>,
where T1 and T2 are the types
represented by dealias(t1) and dealias(t2), respectively[.](#12.sentence-1)