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

64 lines
3.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

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

[basic.splice]
# 6 Basics [[basic]](./#basic)
## 6.6 Splice specifiers [basic.splice]
[splice-specifier:](#nt:splice-specifier "6.6Splice specifiers[basic.splice]")
[: [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]") :]
[splice-specialization-specifier:](#nt:splice-specialization-specifier "6.6Splice specifiers[basic.splice]")
[*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") < [*template-argument-list*](temp.names#nt:template-argument-list "13.3Names of template specializations[temp.names]")opt >
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2822)
The [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]") of a [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") shall be a converted constant expression of
type std::meta::info ([[expr.const]](expr.const "7.7Constant expressions"))[.](#1.sentence-1)
A [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") whose converted [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]") represents
a construct X is said to [*designate*](#def:designate "6.6Splice specifiers[basic.splice]") either
- [(1.1)](#1.1)
the underlying entity of X if X is an entity ([[basic.pre]](basic.pre "6.1Preamble")), or
- [(1.2)](#1.2)
X otherwise[.](#1.sentence-2)
[*Note [1](#note-1)*:
A [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") is dependent
if the converted [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]") is
value-dependent ([[temp.dep.splice]](temp.dep.splice "13.8.3.5Dependent splice specifiers"))[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2839)
A non-dependent [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") of
a [*splice-specialization-specifier*](#nt:splice-specialization-specifier "6.6Splice specifiers[basic.splice]") shall designate a template[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L2843)
[*Note [2](#note-2)*:
A < following a [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") is interpreted as
the delimiter of a [*template-argument-list*](temp.names#nt:template-argument-list "13.3Names of template specializations[temp.names]") when the [*splice-specifier*](#nt:splice-specifier "6.6Splice specifiers[basic.splice]") is preceded by
the keyword template or the keyword typename, or
when it appears in a type-only context ([[temp.names]](temp.names "13.3Names of template specializations"))[.](#3.sentence-1)
[*Example [1](#example-1)*: constexpr int v = 1;template<int V> struct TCls {static constexpr int s = V + 1;};
using alias = [:^^TCls:]<([:^^v:])>; // OK, a [*splice-specialization-specifier*](#nt:splice-specialization-specifier "6.6Splice specifiers[basic.splice]") with a parenthesized [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9Expression splicing[expr.prim.splice]") 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 [:v:]; // error: v is not constant} — *end example*]
— *end note*]