You can call the translation operator either if it was not a template:
int x = from_string(s).operator int();
or how is it
int x = from_string(s).template operator int();
As a workaround to specify the second template parameter explicitly:
struct converter { std::string to_convert; template <class T, class CI > operator T() { CI ci = CI{std::move(to_convert)}; return ci; } template <class T, class CI> T cast() { CI ci = CI{std::move(to_convert)}; return ci; } };
and use it as follows:
auto y = from_string(s).cast<int, converter_impl<int> >();
source share