This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
(From submission #825.)
Consider:
template<int> int x [[=1]]; template<int A> int y [[=A]]; static_assert(annotations_of(^^x<0>) == annotations_of(^^x<1>)); // #1 static_assert(annotations_of(^^y<0>) == annotations_of(^^y<1>)); // #2
Subclause 9.13.12 [dcl.attr.annotation] paragraph 3 specifies:
Each annotation produces a unique annotation.
It is unclear whether each instantiation of a template creates a distinct annotation.
Suggested resolution:
Change in 9.13.12 [dcl.attr.annotation] paragraph 3 and paragraph 4 as follows:
(3) Each annotation produces a unique annotation.
Substituting into an annotation is not in the immediate context.
[Example:[[=1]] void f(); [[=2, =3, =2]] void g(); void g [[=4, =2]] ();f has one annotation and g has five annotations. These can be queried with metafunctions such as std::meta::annotations_of (21.4.12 [meta.reflection.annotation]). —end example][Example:template<int> int x [[=1]]; static_assert(annotations_of(^^x<0>) != annotations_of(^^x<1>)); // OK-- end example](4) Substituting into an annotation is not in the immediate context.
[Example:
template<class T> [[=T::type()]] void f(T t); void f(int); void g() { f(0); // OK f('0'); // error, ... }-- end example]