
Hi,
I would like to detect if the return type of a function is void or not within C++03 standard?
You can specialize on function type (provided that the arguments are known). template <typename T> struct check_void : boost::false_type {}; template <> struct check_void<void (*)()> : boost::true_type {}; void returns_void() {} int returns_int() { return 0; } template <typename F> void test_type(F function) { std::cout << typeid(F).name() << (check_void<F>::value ? " true" : " false") << std::endl; } int test_main(int, char* []) { test_type(returns_void); test_type(returns_int); ...
I need that to implement new type traits to detect if types can be compared and to detect for example operator< returning void.
I don't know if you can use it like this on an operator< returning void. Regards, Barend