According to error clang does not have a problem with deducing template template-parameter which is also standard compliant - [temp.arg.template]/3 (empasis mine):
A template-argument matches a template template-parameter P when P is
at least as specialized as the template-argument A. If P contains a
parameter pack, then A also matches P if each of A's template
parameters matches the corresponding template parameter in the
template-parameter-list of P. Two template parameters match if they
are of the same kind (type, non-type, template), for non-type
template-parameters, their types are equivalent ([temp.over.link]),
and for template template-parameters, each of their corresponding
template-parameters matches, recursively. When P's
template-parameter-list contains a template parameter pack, the
template parameter pack will match zero or more template parameters or
template parameter packs in the template-parameter-list of A with the
same type and form as the template parameter pack in P (ignoring
whether those template parameters are template parameter packs)
Now lets make sure the Bar<(x)>{}
should be deduced as reference. This is covered by [dcl.type.auto.deduct]/5 and [dcl.type.simple]/4.
Finally lets check if we actually can use the reference to the variable with linkage as a template argument [temp.arg.nontype]/2:
A template-argument for a non-type template-parameter shall be a
converted constant expression of the type of the template-parameter.
For a non-type template-parameter of reference or pointer type, the
value of the constant expression shall not refer to (or for a pointer
type, shall not be the address of):
- a subobject,
- a temporary object,
- a string literal,
- the result of a typeid expression, or
- a predefined func__ variable.
[ Note: If the template-argument represents a set of overloaded
functions (or a pointer or member pointer to such), the matching
function is selected from the set ([over.over]). — end note ]
The deduced argument fulfils the requirements. This makes the code well-formed and suggests clang's bug.
Filed bug 34690
TT
is a template template-parameter, that deduces toBar
just fine? clang's problem is in deducingV
– Gwyndecltype(auto)
. Not a template. Appearantly I just misread. – Munceyfoo
just betemplate <decltype(auto) V> void foo(Bar<V> ) { }
- same behavior, just one less variable – Gwyn