Subject: Re: [boost] [utility] Adding noexcept to boost::declval
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-03-26 11:33:52
(Forgot to send to the list; now back to the list again.)
Vicente J. Botet Escriba wrote:
> OK, I will rollback it and analyze the breaking change.
The important thing is that declval<T>() should preserve
the constness/non-constness and the rvalueness/lvalueness of T.
Essentially, it's OK to define declval<T>() as simply T.
Then, why declval<T>() is defined as add_rvalue_reference<T>::type?
This is because
* When declval<T>() is defined as T, we cannot use abstract types as T.
* When declval<T>() is defined as T&&, we cannot use void as T.
The definition with add_rvalue_reference<T>::type also allows to use
incomplete types as T.
In C++03, it is not possible to construct rvalues of abstract types or
incomplete types. So, the correct way to define declval<T>() in C++03
is to just use T. And this is the definition of declval<T>() in the previous
version of boost::declval when BOOST_NO_RVALUE_REFERENCES is defined.
Defining declval<T>() as add_lvalue_reference<T>::type is wrong;
add_lvalue_reference should be removed!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk