I have an unfortunate class setup that I am stuck with and I need to call a simple function that is specialized for each variation of the class.
Below is a simplified version of the code that shows the problem.
https://godbolt.org/z/hjh3a8Tqo
template <typename T>
struct ValueT {};
struct Container1 {
using Value = ValueT<Container1>;
};
struct Container2 {
using Value = ValueT<Container2>;
};
template <typename T>
struct Container3 {
using Base = T;
struct Value : ValueT<Container3> {
typename Base::Value asBase() { return {}; }
};
};
void handle(const Container1::Value &v) {}
void handle(const Container2::Value &v) {}
template<typename T>
void handle(const typename Container3<T>::Value &v) {
return handle(v.asBase());
}
int main()
{
Container1::Value v1;
Container2::Value v2;
Container3<Container1>::Value v31;
Container3<Container2>::Value v32;
handle(v1);
handle(v2);
handle(v31);
handle(v32);
return 0;
}
I’ve tried several several approaches to get handle(Container3::Value&)
to work. Up to and including template template template parameters
! But, I can’t find the right angle to come at it.
corysama is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.