has_trivial_copy_assign hooked up to clang (without workarounds). Filed http://llvm.org/bugs/show_bug.cgi?id=8109 to take care of several types which don't work yet. If there is some reason we don't want to handle these types in the compiler, I can handle most of them in the library.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@113312 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
954b366317
commit
99ad765261
@ -769,20 +769,14 @@ template <class _Tp> struct has_copy_assign;
|
||||
|
||||
#if defined(__clang__) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
|
||||
|
||||
template <class _Tp, bool = is_void<_Tp>::value>
|
||||
struct __has_trivial_copy_assign
|
||||
: public integral_constant<bool, __has_trivial_assign(_Tp)> {};
|
||||
|
||||
template <class _Tp> struct __has_trivial_copy_assign<_Tp, true>
|
||||
: public false_type {};
|
||||
|
||||
template <class _Tp> struct has_trivial_copy_assign
|
||||
: __has_trivial_copy_assign<_Tp> {};
|
||||
: public integral_constant<bool, __has_trivial_assign(_Tp)> {};
|
||||
|
||||
#else
|
||||
|
||||
template <class _Tp> struct has_trivial_copy_assign
|
||||
: public integral_constant<bool, is_scalar<_Tp>::value && !is_const<_Tp>::value> {};
|
||||
: public integral_constant<bool, is_scalar<_Tp>::value &&
|
||||
!is_const<_Tp>::value> {};
|
||||
|
||||
#endif // defined(__clang__) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
|
||||
|
||||
|
@ -13,22 +13,10 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
template <class T>
|
||||
template <class T, bool Result>
|
||||
void test_has_trivial_assign()
|
||||
{
|
||||
static_assert( std::has_trivial_copy_assign<T>::value, "");
|
||||
static_assert(!std::has_trivial_copy_assign<const T>::value, "");
|
||||
static_assert( std::has_trivial_copy_assign<volatile T>::value, "");
|
||||
static_assert(!std::has_trivial_copy_assign<const volatile T>::value, "");
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_has_not_trivial_assign()
|
||||
{
|
||||
static_assert(!std::has_trivial_copy_assign<T>::value, "");
|
||||
static_assert(!std::has_trivial_copy_assign<const T>::value, "");
|
||||
static_assert(!std::has_trivial_copy_assign<volatile T>::value, "");
|
||||
static_assert(!std::has_trivial_copy_assign<const volatile T>::value, "");
|
||||
static_assert(std::has_trivial_copy_assign<T>::value == Result, "");
|
||||
}
|
||||
|
||||
class Empty
|
||||
@ -59,19 +47,20 @@ struct A
|
||||
|
||||
int main()
|
||||
{
|
||||
test_has_not_trivial_assign<void>();
|
||||
test_has_not_trivial_assign<A>();
|
||||
test_has_not_trivial_assign<int&>();
|
||||
test_has_not_trivial_assign<NotEmpty>();
|
||||
test_has_not_trivial_assign<Abstract>();
|
||||
test_has_trivial_assign<void, false>();
|
||||
test_has_trivial_assign<A, false>();
|
||||
test_has_trivial_assign<int&, false>();
|
||||
test_has_trivial_assign<NotEmpty, false>();
|
||||
test_has_trivial_assign<Abstract, false>();
|
||||
test_has_trivial_assign<const Empty, false>();
|
||||
test_has_trivial_assign<char[3], false>();
|
||||
test_has_trivial_assign<char[], false>();
|
||||
|
||||
test_has_trivial_assign<Union>();
|
||||
test_has_trivial_assign<Empty>();
|
||||
test_has_trivial_assign<int>();
|
||||
test_has_trivial_assign<double>();
|
||||
test_has_trivial_assign<int*>();
|
||||
test_has_trivial_assign<const int*>();
|
||||
test_has_trivial_assign<char[3]>();
|
||||
test_has_trivial_assign<char[3]>();
|
||||
test_has_trivial_assign<bit_zero>();
|
||||
test_has_trivial_assign<Union, true>();
|
||||
test_has_trivial_assign<Empty, true>();
|
||||
test_has_trivial_assign<int, true>();
|
||||
test_has_trivial_assign<double, true>();
|
||||
test_has_trivial_assign<int*, true>();
|
||||
test_has_trivial_assign<const int*, true>();
|
||||
test_has_trivial_assign<bit_zero, true>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user