Boost logo

Boost :

Subject: Re: [boost] [type_traits][parameter] Inconsistent boost::is_convertible between gcc and clang
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-08-13 22:16:32


Michel Morin wrote:
> The following code works well (incl. your mentioned cases)
> both in C++03 and C++11 on gcc.
<snip>
> static bool const rval_to_nonconst_lval_ref_conv = ::boost::type_traits::ice_and<
> !(::boost::is_function<From>::value) // Note: an rvalue ref to function type is an lvalue
> , !(::boost::is_reference<From>::value)
> , ::boost::is_reference<To>::value
> , !(::boost::is_const<typename ::boost::remove_reference<To>::type>::value)
> >::value;

Sorry, the above code is wrong. It does not detect binding
const volatile reference to an rvalue.
Here is a right code:

    static bool const rval_to_nonconst_lval_ref_conv =
::boost::type_traits::ice_and<
        !(::boost::is_function<From>::value) // Note: an rvalue ref to
function type is an lvalue
      , !(::boost::is_reference<From>::value)
      , ::boost::is_reference<To>::value
      , ::boost::type_traits::ice_or<
            !::boost::is_const<typename
::boost::remove_reference<To>::type>::value
          , ::boost::type_traits::ice_and<
                ::boost::is_const<typename
::boost::remove_reference<To>::type>::value
              , ::boost::is_volatile<typename
::boost::remove_reference<To>::type>::value
>::value
>::value
>::value;

Regards,
Michel


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