[expr.prim.splice]

# 7 Expressions [[expr]](./#expr)

## 7.5 Primary expressions [[expr.prim]](expr.prim#splice)

### 7.5.9 Expression splicing [expr.prim.splice]

[splice-expression:](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")  
[*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]")  
template [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]")  
template [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]")

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L3516)

A [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") or [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]") immediately followed by ​::​ or preceded by typename is never interpreted as part of a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")[.](#1.sentence-1)

[*Example [1](#example-1)*: struct S { static constexpr int a = 1; };template<typename> struct TCls { static constexpr int b = 2; };

constexpr int c = [:^^S:]::a; // OK, [:^^S:] is not an expressionconstexpr int d = template [:^^TCls:]<int>::b; // OK, template [:^^TCls:]<int> is not an expressiontemplate<auto V> constexpr int e = [:V:]; // OKconstexpr int f = template [:^^e:]<^^S::a>; // OKconstexpr auto g = typename [:^^int:](42); // OK, typename [:^^int:] is a [*splice-type-specifier*](dcl.type.splice#nt:splice-type-specifier "9.2.9.9 Type splicing [dcl.type.splice]")constexpr auto h = ^^g;constexpr auto i = e<[:^^h:]>; // error: unparenthesized [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") used as template argumentconstexpr auto j = e<([:^^h:])>; // OK â *end example*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L3539)

For a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") of the form [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]"),
let S be the construct designated by [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]")[.](#2.sentence-1)

- [(2.1)](#2.1)

  The expression is ill-formed if S is
  * [(2.1.1)](#2.1.1)

a constructor,

  * [(2.1.2)](#2.1.2)

a destructor,

  * [(2.1.3)](#2.1.3)

an unnamed bit-field, or

  * [(2.1.4)](#2.1.4)

a local entity ([[basic.pre]](basic.pre "6.1 Preamble")) such that
    +
          [(2.1.4.1)](#2.1.4.1)
there is a lambda scope that intervenes
between the expression and the point at which S was introduced and

    +
          [(2.1.4.2)](#2.1.4.2)
the expression would be potentially evaluated
if the effect of any enclosing typeid expressions ([[expr.typeid]](expr.typeid "7.6.1.8 Type identification"))
were ignored[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  Otherwise, if S is a function F,
the expression denotes an overload set containing all declarations of F that precede either the expression or
the point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1 Preamble [class.pre]") of
the outermost class for which the expression is in a complete-class context;
overload resolution is performed ([[over.match]](over.match "12.2 Overload resolution"), [[over.over]](over.over "12.3 Address of an overload set"))[.](#2.2.sentence-1)

- [(2.3)](#2.3)

  Otherwise, if S is an object or a non-static data member,
the expression is an lvalue designating S[.](#2.3.sentence-1)
  The expression has the same type as that of S, and
is a bit-field if and only if S is a bit-field[.](#2.3.sentence-2)
  [*Note [1](#note-1)*:
  The implicit transformation
whereby an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") denoting a non-static member
becomes a class member access ([[expr.prim.id]](expr.prim.id "7.5.5 Names"))
does not apply to a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")[.](#2.3.sentence-3)
 â *end note*]

- [(2.4)](#2.4)

  Otherwise, if S is a variable or a structured binding,S shall either have static or thread storage duration or
shall inhabit a scope enclosing the expression[.](#2.4.sentence-1)
  The expression is an lvalue referring to the object or function X associated with or referenced by S,
has the same type as that of S, and
is a bit-field if and only if X is a bit-field[.](#2.4.sentence-2)
  [*Note [2](#note-2)*:
  The type of a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") designating a variable or structured binding of reference type
will be adjusted to a non-reference type ([[expr.type]](expr.type "7.2.2 Type"))[.](#2.4.sentence-3)
 â *end note*]

- [(2.5)](#2.5)

  Otherwise, if S is a value or an enumerator,
the expression is a prvalue that computes S and
whose type is the same as that of S[.](#2.5.sentence-1)

- [(2.6)](#2.6)

  Otherwise, the expression is ill-formed[.](#2.6.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L3603)

For a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") of
the form template [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]"),
the [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") shall designate a function template T that is not a constructor template[.](#3.sentence-1)

The expression denotes an overload set containing all declarations of T that precede either the expression or
the point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1 Preamble [class.pre]") of
the outermost class for which the expression is in a complete-class context;
overload resolution is performed[.](#3.sentence-2)

[*Note [3](#note-3)*:

During overload resolution,
candidate function templates undergo template argument deduction and
the resulting specializations are considered as candidate functions[.](#3.sentence-3)

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L3619)

For a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") of
the form template [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]"),
the [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") of
the [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]") shall designate a template T[.](#4.sentence-1)

- [(4.1)](#4.1)

  If T is a function template,
the expression denotes an overload set containing all declarations of T that precede either the expression or
the point immediately following the [*class-specifier*](class.pre#nt:class-specifier "11.1 Preamble [class.pre]") of
the outermost class for which the expression is in a complete-class context;
overload resolution is performed ([[over.match]](over.match "12.2 Overload resolution"), [[over.over]](over.over "12.3 Address of an overload set"))[.](#4.1.sentence-1)

- [(4.2)](#4.2)

  Otherwise, if T is a variable template,
let S be the specialization of T corresponding to
the template argument list of the [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]")[.](#4.2.sentence-1)
  The expression is an lvalue referring to
the object associated with S and has the same type as that of S[.](#4.2.sentence-2)

- [(4.3)](#4.3)

  Otherwise, the expression is ill-formed[.](#4.3.sentence-1)

[*Note [4](#note-4)*:

Class members are accessible from any point
when designated by [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")*s* ([[class.access.base]](class.access.base "11.8.3 Accessibility of base classes and base class members"))[.](#4.sentence-2)

A class member access expression ([[expr.ref]](expr.ref "7.6.1.5 Class member access"))
whose right operand is a [*splice-expression*](#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") is ill-formed
if the left operand (considered as a pointer) cannot be implicitly converted
to a pointer to the designating class of the right operand[.](#4.sentence-3)

â *end note*]
