
Eric Niebler wrote:
Frédéric Bron wrote:
Eric Niebler wrote:
I solved this problem once while writing a different trait and documented it here: http://www.boost.org/doc/libs/1_41_0/doc/html/proto/appendices.html#boost_pr...
This does not check for return type but just ignores it with the operator, trick. In the end, you do not know if fun(a,b) return void or not.
I find your lack of faith disturbing. <snip>
Corrected version... #include <boost/static_assert.hpp> typedef char yes_type; typedef char (&no_type)[2]; struct void_return { template<typename T> friend int operator,(T const &, void_return); }; no_type check_is_void_return(int); yes_type check_is_void_return(void_return); // check to see if the expression fun(x,y) is void template<typename Fun, typename X, typename Y> struct returns_void { static Fun &fun; static X &x; static Y &y; static bool const value = sizeof(yes_type) == sizeof(check_is_void_return((fun(x,y),void_return()))); }; int main() { BOOST_STATIC_ASSERT((returns_void<void(int,int),int,int>::value == 1)); BOOST_STATIC_ASSERT((returns_void<int(int,int),int,int>::value == 0)); } -- Eric Niebler BoostPro Computing http://www.boostpro.com