I have a templated class that can take either a scalar, or an indexed type, and I would like to call a different version of a function depending on what type it is:
template <typename Ta, typename ... T>
struct MyClass {
Ta tt; //can be either a scalar (double, complex<double>, int, etc),
//or an indexed type (MyClass, std::vector<double>, double[], etc)
//....
//I would like the following to be called when tt is a scalar type:
auto operator[]( size_t i ) { return tt; };
//I would like the following to be called when tt has [] overloaded:
auto operator[]( size_t i ) { return tt[i]; };
};
Is there a way to do this? Return value SFINAE doesn't work (because there isn't a template parameter on this function), Class based SFINAE doesn't seem to work (because the variadic template makes having a dummy template parameter at the end not work). Any other ideas?