forked from boostorg/type_traits
Fix has_trivial_copy so that non-copyable types are never trivially copyable! Also fix clang to detect trivially copyable array types.
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
#include <boost/type_traits/detail/ice_or.hpp>
|
||||
#include <boost/type_traits/detail/ice_not.hpp>
|
||||
|
||||
#ifdef __clang__
|
||||
#include <boost/type_traits/is_copy_constructible.hpp>
|
||||
#endif
|
||||
|
||||
// should be the last #include
|
||||
#include <boost/type_traits/detail/bool_trait_def.hpp>
|
||||
|
||||
@@ -28,7 +32,11 @@ template <typename T>
|
||||
struct has_trivial_copy_impl
|
||||
{
|
||||
#ifdef BOOST_HAS_TRIVIAL_COPY
|
||||
# ifdef __clang__
|
||||
BOOST_STATIC_CONSTANT(bool, value = BOOST_HAS_TRIVIAL_COPY(T) && boost::is_copy_constructible<T>::value);
|
||||
# else
|
||||
BOOST_STATIC_CONSTANT(bool, value = BOOST_HAS_TRIVIAL_COPY(T));
|
||||
# endif
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::type_traits::ice_and<
|
||||
@@ -38,6 +46,16 @@ struct has_trivial_copy_impl
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct has_trivial_copy_impl<T[N]>
|
||||
{
|
||||
static const bool value = has_trivial_copy_impl<T>::value;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_trivial_copy,T,::boost::detail::has_trivial_copy_impl<T>::value)
|
||||
|
@@ -12,6 +12,19 @@
|
||||
# include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
|
||||
|
||||
class bug_10389
|
||||
{
|
||||
int m_data;
|
||||
public:
|
||||
bug_10389() { m_data = 0; }
|
||||
bug_10389(const bug_10389&) = delete;
|
||||
bug_10389(bug_10389&& r) : m_data(r.m_data) { r.m_data = 0; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(has_trivial_copy)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<bool>::value, true);
|
||||
@@ -203,6 +216,10 @@ BOOST_CHECK_SOFT_INTEGRAL_CONSTANT(::tt::has_trivial_copy<wrap<trivial_except_as
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<test_abc1>::value, false);
|
||||
|
||||
#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<bug_10389>::value, false);
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user