diff --git a/include/type_traits b/include/type_traits index 9ae3d6f6..0f45f489 100644 --- a/include/type_traits +++ b/include/type_traits @@ -761,10 +761,6 @@ template struct has_nothrow_copy_constructor template struct has_nothrow_move_constructor : public has_nothrow_copy_constructor<_Tp> {}; -// has_copy_constructor - -template struct has_copy_constructor : public true_type {}; - // has_copy_assign template struct has_copy_assign; @@ -1732,6 +1728,24 @@ struct __is_constructible0_imp #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +// has_copy_constructor + +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + +template +struct has_copy_constructor + : public is_constructible<_Tp, typename add_lvalue_reference::type> + {}; + +#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE + +template +struct has_copy_constructor + : public has_nothrow_copy_constructor<_Tp> + {}; + +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + template struct __is_zero_default_constructible : public integral_constant::value || is_empty<_Tp>::value> {}; diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp index 7acb6950..f3364c1c 100644 --- a/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp +++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_copy_constructor.pass.cpp @@ -13,7 +13,55 @@ #include +template +void test_has_copy_constructor() +{ + static_assert(std::has_copy_constructor::value == Result, ""); +} + +class Empty +{ +}; + +class NotEmpty +{ +public: + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ +public: + virtual ~Abstract() = 0; +}; + +struct A +{ + A(const A&); +}; + int main() { -#error has_copy_constructor not implemented + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); + test_has_copy_constructor(); } diff --git a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp index f2ebadd4..8dbd3e8e 100644 --- a/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp +++ b/test/utilities/meta/meta.unary/meta.unary.prop/has_nothrow_copy_constructor.pass.cpp @@ -61,11 +61,11 @@ struct A int main() { -// test_has_not_nothrow_copy_constructor(); + test_has_not_nothrow_copy_constructor(); test_has_not_nothrow_copy_constructor(); test_has_not_nothrow_copy_constructor(); -// test_has_not_nothrow_copy_constructor(); -// test_has_not_nothrow_copy_constructor(); + test_has_not_nothrow_copy_constructor(); + test_has_not_nothrow_copy_constructor(); test_has_nothrow_copy_constructor(); test_has_nothrow_copy_constructor(); @@ -74,6 +74,6 @@ int main() test_has_nothrow_copy_constructor(); test_has_nothrow_copy_constructor(); test_has_nothrow_copy_constructor(); -// test_has_nothrow_copy_constructor(); + test_has_nothrow_copy_constructor(); test_has_nothrow_copy_constructor(); }