I want to have a certain function that does a computation if the Argument is a certain template with a specific first template parameter (arbitrarily templated).
Consider these classes
template<class S> struct A { };
template<class S> struct B { };
template<class S> struct C { };
template<class S, class U = B<S>> struct D { };
I tried to achieve my goal using
template<template<class ... X> class Y, class Z>
inline void foo(Y<A<Z>> const &av) { std::cout << "2\n"; }
Problem: MSVS 2013 is not able to deduce Y
.
int main()
{
foo(C<A<int>>()); // prints 2 as intended
foo(D<A<int>>()); // does NOT compile in VS 2013
return 0;
}
The reason for the error (according to MSVS) is:
template-Argument for
const Y<A<Z>> &
cannot be deduced fromD<A<int>, B<S>>
withS=A<int>
.
My goal is to write an overload / specialization that handles any given type Y
where Y::value_type
/ the first template parameter of Y
can be any A<T>
where the signature of foo is to be preserved: void foo (Y const &);
Is this a Bug in MSVS (since foo(D<A<int>>());
does in fact print 2 using g++) or am I missing something?
PS: Merry Christmas if you care...