You can't have two functions that differ in just the return type in C++
template<typename T>
T my_construct() { T result; return result; }edit: you get pseudo call-by-name as a bonus.
struct PolyReturn {
const int value;
operator int() const { return value; }
operator bool() const { return value > 0; }
};
https://cppinsights.io/s/f0b9976f