mirror of
https://github.com/boostorg/optional.git
synced 2025-07-25 01:57:14 +02:00
Sane swap() for rvalue-aware compilers
When we detect that compiler supports rvalue references, we implement swap() in term of moves (as intuition suggests). Otherwise we fall back to old tricks with default constructor+swap
This commit is contained in:
@ -1543,9 +1543,18 @@ struct swap_selector<false>
|
||||
|
||||
} // namespace optional_detail
|
||||
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_CONFIG_RESTORE_OBSOLETE_SWAP_IMPLEMENTATION)
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : boost::false_type {} ;
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor<T> {} ;
|
||||
|
||||
#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template<class T> inline void swap ( optional<T>& x, optional<T>& y )
|
||||
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user