[expr.prim.splice] (original) (raw)

7 Expressions [expr]

7.5 Primary expressions [expr.prim]

7.5.9 Expression splicing [expr.prim.splice]

[Example 1: struct S { static constexpr int a = 1; };template<typename> struct TCls { static constexpr int b = 2; };constexpr int c = [:^^S:]::a; constexpr int d = template [:^^TCls:]<int>::b; template<auto V> constexpr int e = [:V:]; constexpr int f = template [:^^e:]<^^S::a>; constexpr auto g = typename [:^^int:](42); constexpr auto h = ^^g;constexpr auto i = e<[:^^h:]>; constexpr auto j = e<([:^^h:])>; — _end example_]

For a splice-expression of the form template splice-specifier, the splice-specifier shall designate a function template Tthat is not a constructor template.

The expression denotes an overload set containing all declarations of Tthat precede either the expression or the point immediately following the class-specifier of the outermost class for which the expression is in a complete-class context; overload resolution is performed.

[Note 3:

During overload resolution, candidate function templates undergo template argument deduction and the resulting specializations are considered as candidate functions.

— _end note_]

[Note 4:

Class members are accessible from any point when designated by splice-expressions ([class.access.base]).

A class member access expression ([expr.ref]) whose right operand is a splice-expression 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.

— _end note_]