struct Bob
{
template<class T>
void operator () () const
{
T t;
}
template<class T>
operator T () const
{
T t;
return t;
}
};
I can directly call Bob's operator() like this
Bob b;
b.operator()<int>();
How to directly call the conversion operator with a specific template parameter like this?
Bob b;
std::string s = b.???<std::string>();
It's not possible to use static_cast
Bob b;
std::string s = static_cast<std::string>(b);
error: call of overloaded ‘basic_string(Bob&)’ is ambiguous
Question How to call directly with template parameter OR it's not possible. I know there are workarounds using a wrapping function.