I'm trying to use a subclass from an other class as parameter for template function:
template<typename T> class Class1{
public:
class Sub1{};
};
template<typename T> class Class2{
public:
Class2() = default;
template<typename T_other> void func(const typename Class1<T_other>::Sub1 sub) {}
};
// ...code
Class1<int>::Sub1 sub1;
Class2<float> class2;
class2.func( sub1); //ERROR
The error says:
error: no matching function for call to ???Class2<float>::func(Class1<int>::Sub1&)???
class2.func( sub1); //ERROR
^
note: candidate: ???template<class T_other> void Class2<T>::func(typename Class1<T_other>::Sub1) [with T_other = T_other; T = float]???
template<typename T_other> void func(const typename Class1<T_other>::Sub1 sub) {}
^~~~
note: template argument deduction/substitution failed:
note: couldn't deduce template parameter ???T_other???
What is wrong? The error message says the correct type (Class1<int>::Sub1
)so why can't it deduce it?