mirror of
https://github.com/boostorg/type_traits.git
synced 2025-07-29 12:07:20 +02:00
Reuse is_swappable implementation in is_nothrow_swappable for gcc < 4.7.
This avoids applying noexcept operator to a potentially invalid swap expression, which should resolve ICE with gcc 4.6.
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
[h4 Boost-1.82.0]
|
||||
|
||||
* Added __is_swappable trait.
|
||||
* Added a workaround for gcc 4.6 that allows __is_nothrow_swappable to work.
|
||||
|
||||
[h4 Boost-1.70.0]
|
||||
|
||||
|
@ -34,7 +34,22 @@ template<class T> boost::false_type is_swappable_impl( ... );
|
||||
template<class T>
|
||||
struct is_swappable_helper { typedef decltype( boost_type_traits_swappable_detail::is_swappable_impl<T>(0) ) type; };
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
// gcc 4.6 ICEs when noexcept operator is used on an invalid expression
|
||||
template<class T, class U, bool = is_swappable_with_helper<T, U>::type::value>
|
||||
struct is_nothrow_swappable_with_helper { typedef boost::false_type type; };
|
||||
template<class T, class U>
|
||||
struct is_nothrow_swappable_with_helper<T, U, true> { typedef boost::integral_constant<bool, noexcept(swap(boost::declval<T>(), boost::declval<U>()))> type; };
|
||||
|
||||
template<class T, bool = is_swappable_helper<T>::type::value>
|
||||
struct is_nothrow_swappable_helper { typedef boost::false_type type; };
|
||||
template<class T>
|
||||
struct is_nothrow_swappable_helper<T, true> { typedef boost::integral_constant<bool, noexcept(swap(boost::declval<T&>(), boost::declval<T&>()))> type; };
|
||||
|
||||
#else // BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
template<class T, class U, bool B = noexcept(swap(boost::declval<T>(), boost::declval<U>()))> boost::integral_constant<bool, B> is_nothrow_swappable_with_impl( int );
|
||||
template<class T, class U> boost::false_type is_nothrow_swappable_with_impl( ... );
|
||||
@ -46,7 +61,9 @@ template<class T> boost::false_type is_nothrow_swappable_impl( ... );
|
||||
template<class T>
|
||||
struct is_nothrow_swappable_helper { typedef decltype( boost_type_traits_swappable_detail::is_nothrow_swappable_impl<T>(0) ) type; };
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT) && !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
#endif // BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT)
|
||||
|
||||
} // namespace boost_type_traits_swappable_detail
|
||||
|
||||
|
@ -8,10 +8,9 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_DECLTYPE) \
|
||||
|| defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) || BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
|| defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
||||
|
||||
#include <boost/type_traits/is_scalar.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
// These conditions should be similar to those in is_nothrow_swappable.hpp
|
||||
#if defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_NO_CXX11_NOEXCEPT) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) \
|
||||
|| BOOST_WORKAROUND(BOOST_GCC, < 40700) \
|
||||
|| (defined(__GLIBCXX__) && __GLIBCXX__ <= 20120301) // built-in clang++ -std=c++11 on Travis, w/ libstdc++ 4.6
|
||||
#define BOOST_TYPE_TRAITS_IS_NOTHROW_SWAPPABLE_EMULATED
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user