Skip to content

Commit

Permalink
Update is_trivially_copyable implementation for user move with defaul…
Browse files Browse the repository at this point in the history
…ted copy
  • Loading branch information
glenfe committed Aug 14, 2020
1 parent 5588bb1 commit c6c7ff1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/boost/type_traits/is_trivially_copyable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ 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 {

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 */
Expand Down
18 changes: 16 additions & 2 deletions test/is_trivially_copyable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit c6c7ff1

Please sign in to comment.