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?
The code is perfectly fine in C++11. The Clang's warning can be ignored.
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>>{};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With