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

3.7 KiB
Raw Permalink Blame History

[basic.splice]

6 Basics [basic]

6.6 Splice specifiers [basic.splice]

splice-specifier:
[: constant-expression :]

splice-specialization-specifier:
splice-specifier < template-argument-listopt >

1

#

The constant-expression of a splice-specifier shall be a converted constant expression of type std::meta::info ([expr.const]).

A splice-specifier whose converted constant-expression represents a construct X is said to designate either

the underlying entity of X if X is an entity ([basic.pre]), or

X otherwise.

[Note 1:

A splice-specifier is dependent if the converted constant-expression is value-dependent ([temp.dep.splice]).

— end note]

2

#

A non-dependent splice-specifier of a splice-specialization-specifier shall designate a template.

3

#

[Note 2:

A < following a splice-specifier is interpreted as the delimiter of a template-argument-list when the splice-specifier is preceded by the keyword template or the keyword typename, or when it appears in a type-only context ([temp.names]).

[Example 1: constexpr int v = 1;template struct TCls {static constexpr int s = V + 1;};

using alias = [:^^TCls:]<([:^^v:])>; // OK, a splice-specialization-specifier with a parenthesized splice-expression as a template argumentstatic_assert(alias::s == 2);

auto o1 = [:^^TCls:]<([:^^v:])>(); // error: < means less thanauto o2 = typename [:^^TCls:]<([:^^v:])>(); // OK, o2 is an object of type TCls<1>consteval int bad_splice(std::meta::info v) {return [✌️]; // error: v is not constant} — end example]

— end note]