Reputation: 1797
Given a template alias
template<unsigned U>
using uint_ = integral_constant<unsigned,U>;
The partial specialization of
template<class T,class P>
struct size{};
as
template <class T,unsigned U>
struct size<T,uint_<U>>{};
generates a warning astemplate parameter can not be deduced
for clang 3.1 while no warning is generated with gcc 4.7
So, is it malformed code?
Upvotes: 4
Views: 824
Reputation: 506897
Another guy said that this is a Clang bug. You can work it around if you change the using declaration like this
template<unsigned T, unsigned U = T>
using uint_ = integral_constant<unsigned,U>;
As an educated guess, apparently Clang does not correctly update the identity of the template parameter that appears in the type-id. So it thinks in your example that the resulting type uint_<U>
refers to the first parameter of the partial specialization (because within uint_
that is the case, but not in the point of use). Alternatively you can exchange the order at the point of use
template <unsigned U,class T>
struct size<T,uint_<U>>{};
Upvotes: 3
Reputation: 361322
The code is perfectly fine in C++11. The Clang's warning can be ignored.
Upvotes: 5