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


> The following two types are not used anywhere
>   typedef typename ::boost::remove_cv::type rhs_nocv;
>   typedef typename ::boost::remove_cv< typename ::boost::remove_reference<
> typename ::boost::remove_pointer::type >::type >::type rhs_noptr;
>
> Shouldn't them be removed?

They are used, but not in the example of the doc.
These shortcuts are used extensively in the macro FOBIDDEN_IF which
determines if the operator is forbidden for fundamental types (to
avoid compile time error).
In the doc, I chose a simple case (unary_minus) where FORBIDDEN_IF is
only ::boost::is_pointer< rhs_noref >::value

Here is a more complex example (has_operator_plus.hpp):
#define BOOST_TT_FORBIDDEN_IF\
   ::boost::type_traits::ice_or<\
      /* pointer with pointer */\
      ::boost::type_traits::ice_and<\
         ::boost::is_pointer< lhs_noref >::value,\
         ::boost::is_pointer< rhs_noref >::value\
>::value,\
      /* pointer with fundamental non integral */\
      ::boost::type_traits::ice_and<\
         ::boost::is_pointer< lhs_noref >::value,\
         ::boost::is_fundamental< rhs_nocv >::value,\
         ::boost::type_traits::ice_not< ::boost::is_integral<
rhs_noref >::value >::value\
>::value,\
      ::boost::type_traits::ice_and<\
         ::boost::is_pointer< rhs_noref >::value,\
         ::boost::is_fundamental< lhs_nocv >::value,\
         ::boost::type_traits::ice_not< ::boost::is_integral<
lhs_noref >::value >::value\
>::value,\
      /* void* with fundamental */\
      ::boost::type_traits::ice_and<\
         ::boost::is_pointer< lhs_noref >::value,\
         ::boost::is_void< lhs_noptr >::value,\
         ::boost::is_fundamental< rhs_nocv >::value\
>::value,\
      ::boost::type_traits::ice_and<\
         ::boost::is_pointer< rhs_noref >::value,\
         ::boost::is_void< rhs_noptr >::value,\
         ::boost::is_fundamental< lhs_nocv >::value\
>::value\
>::value

> I have not see the utility of removing the reference
>   typedef typename ::boost::remove_reference::type rhs_noref;

It is just used to know if the operation is forbidden for fundamental
types and pointers. It avoids having everywhere typename
::boost::remove_reference< ... >::type.
When checking for existence of operator, full type qualification is
used (i.e. LHS or RHS).

Frédéric