mirror of
https://github.com/boostorg/type_traits.git
synced 2025-07-29 20:17:21 +02:00
Update is_trivially_copyable implementation for user move with defaulted copy
This commit is contained in:
@ -13,6 +13,8 @@ or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#include <boost/type_traits/has_trivial_assign.hpp>
|
||||
#include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/type_traits/has_trivial_move_assign.hpp>
|
||||
#include <boost/type_traits/has_trivial_move_constructor.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@ -20,6 +22,8 @@ template<class T>
|
||||
struct is_trivially_copyable
|
||||
: integral_constant<bool, has_trivial_copy<T>::value &&
|
||||
has_trivial_assign<T>::value &&
|
||||
has_trivial_move_constructor<T>::value &&
|
||||
has_trivial_move_assign<T>::value &&
|
||||
has_trivial_destructor<T>::value> { };
|
||||
|
||||
} /* boost */
|
||||
|
@ -53,6 +53,17 @@ struct deleted_destruct {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
struct default_copy {
|
||||
default_copy(const default_copy&) = default;
|
||||
default_copy(default_copy&&) { }
|
||||
default_copy& operator=(const default_copy&) = default;
|
||||
default_copy& operator=(default_copy&&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(is_trivially_copyable)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<bool>::value, true);
|
||||
@ -215,10 +226,13 @@ BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<wrap<trivial_exce
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<wrap<trivial_except_assign> >::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<test_abc1>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<private_copy>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<private_assign>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<private_assign>::value, false);
|
||||
#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<deleted_copy>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<deleted_assign>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<deleted_assign>::value, false);
|
||||
#endif
|
||||
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_trivially_copyable<default_copy>::value, false);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
Reference in New Issue
Block a user