Consider:
#include <vector>
template<int N> class B {};
template<int N> class A {};
template<int N, template<int> class T>
void doSomething(T<N> const& my_type) {
//do sth...
}
int main() {
B<42> b;
doSomething(b); //OK
std::vector<A<43>> vec_a;
doSomething(vec_a); //FAIL: "no matching function for call to 'doSomething'
// "candidate template ignored: could not match N against 'A<43>'"
return 0;
}
I understand that instead of binding N with 43, the compiler tries to bind it with A<43> (which make sense since vec_a is of type std::vector<A<43>>
and not of type std::vector<A><43>
or something like that) and logically fails to do so.
What should I do ? (compiler : clang++ 3.3)