This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-11-05


1025. Use of a reference as a non-type template argument

Section: 13.4.3  [temp.arg.nontype]     Status: C++11     Submitter: Mike Miller     Date: 2010-01-31

[Voted into the WP at the November, 2010 meeting.]

The current wording of 13.4.3 [temp.arg.nontype] paragraph 1 does not prevent the use a reference as a non-type template argument. It simply requires

the address of an object or function with external linkage... expressed as & id-expression...

This would presumably (but unintentionally?) allow an example like the following:

 struct S { }; template<S*> struct X { }; S s; S& ref = s; X<&ref> xr; // well-formed? 

The expression &ref is not a constant expression, but the current wording of 13.4.3 [temp.arg.nontype] does not require a constant expression.

Proposed resolution (September, 2010):

Change 13.4.3 [temp.arg.nontype] bullet 1.3 as follows: