[cfe-commits] [libcxx] r151406 - in /libcxx/trunk: include/type_traits test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
Howard Hinnant
hhinnant at apple.com
Fri Feb 24 15:32:26 PST 2012
Author: hhinnant
Date: Fri Feb 24 17:32:26 2012
New Revision: 151406
URL: http://llvm.org/viewvc/llvm-project?rev=151406&view=rev
Log:
Hook up to the new clang __is_trivially_constructible and __is_trivially_assignable traits. Fixes r10925427 and http://llvm.org/bugs/show_bug.cgi?id=12038.
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=151406&r1=151405&r2=151406&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Fri Feb 24 17:32:26 2012
@@ -2219,6 +2219,16 @@
#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if __has_feature(is_trivially_constructible)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_VISIBLE is_trivially_constructible
+ : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
+{
+};
+
+#else // !__has_feature(is_trivially_constructible)
+
template <class _Tp, class... _Args>
struct _LIBCPP_VISIBLE is_trivially_constructible
: false_type
@@ -2241,34 +2251,24 @@
#else
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp>
#endif
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&>
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&>
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
+#endif // !__has_feature(is_trivially_constructible)
+
#else // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _A0 = __is_construct::__nat,
@@ -2278,50 +2278,68 @@
{
};
+#if __has_feature(is_trivially_constructible)
+
+template <class _Tp>
+struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
+ __is_construct::__nat>
+ : integral_constant<bool, __is_trivially_constructible(_Tp)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
+ __is_construct::__nat>
+ : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
+ __is_construct::__nat>
+ : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
+ __is_construct::__nat>
+ : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
+{
+};
+
+#else // !__has_feature(is_trivially_constructible)
+
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, __is_construct::__nat,
__is_construct::__nat>
-#if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_constructor(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp,
__is_construct::__nat>
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, const _Tp&,
__is_construct::__nat>
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
template <class _Tp>
struct _LIBCPP_VISIBLE is_trivially_constructible<_Tp, _Tp&,
__is_construct::__nat>
-#if __has_feature(has_trivial_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_copy(_Tp)>
-#else
: integral_constant<bool, is_scalar<_Tp>::value>
-#endif
{
};
+#endif // !__has_feature(is_trivially_constructible)
+
#endif // _LIBCPP_HAS_NO_VARIADICS
// is_trivially_default_constructible
@@ -2348,46 +2366,42 @@
// is_trivially_assignable
+#if __has_feature(is_trivially_constructible)
+
+template <class _Tp, class _Arg>
+struct is_trivially_assignable
+ : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
+{
+};
+
+#else // !__has_feature(is_trivially_constructible)
+
template <class _Tp, class _Arg>
struct is_trivially_assignable
: public false_type {};
template <class _Tp>
struct is_trivially_assignable<_Tp&, _Tp>
-#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_assign(_Tp)> {};
-#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
-#endif
template <class _Tp>
struct is_trivially_assignable<_Tp&, _Tp&>
-#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_assign(_Tp)> {};
-#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
-#endif
template <class _Tp>
struct is_trivially_assignable<_Tp&, const _Tp&>
-#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_assign(_Tp)> {};
-#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
-#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp>
struct is_trivially_assignable<_Tp&, _Tp&&>
-#if __has_feature(has_trivial_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- : integral_constant<bool, __has_trivial_assign(_Tp)> {};
-#else
: integral_constant<bool, is_scalar<_Tp>::value> {};
-#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // !__has_feature(is_trivially_constructible)
+
// is_trivially_copy_assignable
template <class _Tp> struct _LIBCPP_VISIBLE is_trivially_copy_assignable
Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp?rev=151406&r1=151405&r2=151406&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp Fri Feb 24 17:32:26 2012
@@ -18,8 +18,6 @@
{
static_assert( std::is_trivially_copy_constructible<T>::value, "");
static_assert( std::is_trivially_copy_constructible<const T>::value, "");
- static_assert( std::is_trivially_copy_constructible<volatile T>::value, "");
- static_assert( std::is_trivially_copy_constructible<const volatile T>::value, "");
}
template <class T>
@@ -27,8 +25,6 @@
{
static_assert(!std::is_trivially_copy_constructible<T>::value, "");
static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
- static_assert(!std::is_trivially_copy_constructible<volatile T>::value, "");
- static_assert(!std::is_trivially_copy_constructible<const volatile T>::value, "");
}
class Empty
Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp?rev=151406&r1=151405&r2=151406&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp Fri Feb 24 17:32:26 2012
@@ -17,18 +17,12 @@
void test_is_trivially_move_constructible()
{
static_assert( std::is_trivially_move_constructible<T>::value, "");
- static_assert( std::is_trivially_move_constructible<const T>::value, "");
- static_assert( std::is_trivially_move_constructible<volatile T>::value, "");
- static_assert( std::is_trivially_move_constructible<const volatile T>::value, "");
}
template <class T>
void test_has_not_trivial_move_constructor()
{
static_assert(!std::is_trivially_move_constructible<T>::value, "");
- static_assert(!std::is_trivially_move_constructible<const T>::value, "");
- static_assert(!std::is_trivially_move_constructible<volatile T>::value, "");
- static_assert(!std::is_trivially_move_constructible<const volatile T>::value, "");
}
class Empty
@@ -59,6 +53,20 @@
A(const A&);
};
+#if __has_feature(cxx_defaulted_functions)
+
+struct MoveOnly1
+{
+ MoveOnly1(MoveOnly1&&);
+};
+
+struct MoveOnly2
+{
+ MoveOnly2(MoveOnly2&&) = default;
+};
+
+#endif
+
int main()
{
test_has_not_trivial_move_constructor<void>();
@@ -66,7 +74,6 @@
test_has_not_trivial_move_constructor<Abstract>();
test_has_not_trivial_move_constructor<NotEmpty>();
- test_is_trivially_move_constructible<int&>();
test_is_trivially_move_constructible<Union>();
test_is_trivially_move_constructible<Empty>();
test_is_trivially_move_constructible<int>();
@@ -74,4 +81,9 @@
test_is_trivially_move_constructible<int*>();
test_is_trivially_move_constructible<const int*>();
test_is_trivially_move_constructible<bit_zero>();
+
+#if __has_feature(cxx_defaulted_functions)
+ static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, "");
+ static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, "");
+#endif
}
More information about the cfe-commits
mailing list