Boost logo

Boost Users :

Subject: [Boost-users] boost::any constructors
From: David (list_at_[hidden])
Date: 2016-02-15 16:31:29


boost::any has a perfect forward constructor declared as:

    template<typename ValueType>
    any(ValueType&& value
        , typename boost::disable_if<boost::is_same<any&, ValueType>
>::type* = 0 // disable if value has type `any&`
        , typename boost::disable_if<boost::is_const<ValueType> >::type* =
0) // disable if value has type `const ValueType&&`
      : content(new holder< typename decay<ValueType>::type

The is_const SFINAE exclusion forces const types to the regular copy
    template<typename ValueType>
    any(const ValueType & value)
      : content(new holder<
decay<const ValueType>::type>::type

What is different about how the regular copy constructor treats a constant
value than what the perfect forward construct would do if the is_const
exclusion were removed?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at