#include #include #include using namespace std; template class Filter { Class obj; public: template typename std::result_of::type operator()(Arg const &arg) const { return obj(arg); } }; struct Convert // if there's just one ReturnType operator()(...), simply { // specify `using type = ReturnType' template struct result; double operator()(int x) const { return 12.5; } template struct result { using type = double; }; string operator()(double x) const { return "hello world"s; } template struct result { using type = string; }; }; int main() { Filter fc; cout << fc(5.5).length() << '\n'; cout << fc(5) << '\n'; }