Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Type Traits Extension by Frederic Bron
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2011-03-15 04:52:52


> are you saying that you can check if the return type is actually void? I
> believed that this was not possible, but who knows ...

If you look at the implementation, I must separate implementation for
operators returning void and operators returning non-void.
So I know if the operator returns void or not:

// this intermediate trait has member value of type bool:
// - value==true -> operator- returns void
// - value==false -> operator- does not return void
template < typename RHS >
struct operator_unary_minus_returns_void {
   // overloads of function returns_void make the difference
   // yes_type and no_type have different size by construction
   static ::boost::type_traits::yes_type returns_void(returns_void_t);
   static ::boost::type_traits::no_type returns_void(int);
   static const bool
value=(sizeof(::boost::type_traits::yes_type)==sizeof(returns_void((-make<RHS>(),returns_void_t()))));
};

So it seems that the best would be to have a default RET to
do_no_check and having RET=void really checking if operator- returns
void.
Of course this needs checking... if it really works.

Frédéric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk