"Overload" a function by return type:
https://godbolt.org/z/jYfK1W68j
#include <iostream>
class Caster {
const char* str;
public:
Caster(const char* str) : str{str} {}
template <class T>
operator T() const {
std::cout << "Not implemented: ";
return {};
}
operator int() const {
std::cout << "int: ";
return std::stoi(str);
Comment too long. Click here to view the full text.