diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2014-09-22 23:58:00 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2014-09-22 23:58:00 +0000 |
commit | 0f79772ecccd3340c84b45f00144c7a5d5395cc8 (patch) | |
tree | e897bf874866ee879e4642e196ba3e4aafdb4a1f | |
parent | 15fdcf19ba2ede743600729010756a7480015d9c (diff) | |
download | bcm5719-llvm-0f79772ecccd3340c84b45f00144c7a5d5395cc8.tar.gz bcm5719-llvm-0f79772ecccd3340c84b45f00144c7a5d5395cc8.zip |
Fix some type-traits (is_assignable, etc) dealing with classes that take non-const references as 'right hand side'. Add tests. Fixes PR# 20836
llvm-svn: 218286
6 files changed, 39 insertions, 9 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 7eb0c03b5a3..bd10697cae7 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1523,7 +1523,7 @@ struct is_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable<typename add_lvalue_reference<_Tp>::type, - const typename add_lvalue_reference<_Tp>::type> {}; + typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; // is_move_assignable @@ -2637,8 +2637,8 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible - : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> - {}; + : public is_constructible<_Tp, + typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; // is_move_constructible @@ -2842,8 +2842,7 @@ struct is_trivially_assignable<_Tp&, _Tp&&> template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, - const typename add_lvalue_reference<_Tp>::type> - {}; + typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; // is_trivially_move_assignable @@ -3034,8 +3033,8 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructib // is_nothrow_copy_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible - : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> - {}; + : public is_nothrow_constructible<_Tp, + typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; // is_nothrow_move_constructible @@ -3119,8 +3118,7 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, - const typename add_lvalue_reference<_Tp>::type> - {}; + typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; // is_nothrow_move_assignable diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp index bde44de4c25..c43d59479fb 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp @@ -52,6 +52,11 @@ class B B& operator=(const B&); }; +struct C +{ + void operator=(C&); // not const +}; + int main() { test_is_copy_assignable<int> (); @@ -71,4 +76,5 @@ int main() test_is_not_copy_assignable<B> (); #endif test_is_not_copy_assignable<void> (); + test_is_not_copy_assignable<C> (); } diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp index 837d0b0d218..f878a50c3af 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp @@ -58,6 +58,12 @@ class B B(const B&); }; +struct C +{ + C(C&); // not const + void operator=(C&); // not const +}; + int main() { test_is_copy_constructible<A>(); @@ -75,6 +81,7 @@ int main() test_is_not_copy_constructible<char[]>(); test_is_not_copy_constructible<void>(); test_is_not_copy_constructible<Abstract>(); + test_is_not_copy_constructible<C>(); #if __has_feature(cxx_access_control_sfinae) test_is_not_copy_constructible<B>(); #endif diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp index 3bd2b3b7b80..8fff5f8b3de 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp @@ -34,6 +34,11 @@ struct B void operator=(A); }; +struct C +{ + void operator=(C&); // not const +}; + int main() { test_is_nothrow_assignable<int&, int&> (); @@ -46,4 +51,5 @@ int main() test_is_not_nothrow_assignable<int, int> (); test_is_not_nothrow_assignable<B, A> (); test_is_not_nothrow_assignable<A, B> (); + test_is_not_nothrow_assignable<C, C&> (); } diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp index 8978ec9af53..9d3f8298757 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp @@ -70,6 +70,12 @@ struct A A(const A&); }; +struct C +{ + C(C&); // not const + void operator=(C&); // not const +}; + int main() { test_is_nothrow_constructible<int> (); @@ -80,4 +86,5 @@ int main() test_is_not_nothrow_constructible<A, int> (); test_is_not_nothrow_constructible<A, int, double> (); test_is_not_nothrow_constructible<A> (); + test_is_not_nothrow_constructible<C> (); } diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp index 984824a035d..735d05fa6ee 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp @@ -34,6 +34,11 @@ struct B void operator=(A); }; +struct C +{ + void operator=(C&); // not const +}; + int main() { test_is_trivially_assignable<int&, int&> (); @@ -44,4 +49,5 @@ int main() test_is_not_trivially_assignable<int, int> (); test_is_not_trivially_assignable<B, A> (); test_is_not_trivially_assignable<A, B> (); + test_is_not_trivially_assignable<C&, C&> (); } |