From: Ville Voutilainen Date: Fri, 15 Jul 2016 07:44:22 +0000 (+0300) Subject: Fix the constraints for any's assignment operator template to properly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ec0f76305eae34c9ce6b90d9373dbd5e3ee2701;p=gcc.git Fix the constraints for any's assignment operator template to properly reject assignment from a non-copyable lvalue. From-SVN: r238365 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 68086139cbd..2386300807b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2016-07-14 Ville Voutilainen + + Fix the constraints for any's assignment operator template to properly + reject assignment from a non-copyable lvalue. + * include/std/any (operator=(_ValueType&&)): Constrain the decayed + type for is_copy_constructible, + * testsuite/20_util/any/requirements.cc: Add a test for + non-copyable lvalues. + 2016-07-14 Jonathan Wakely * include/experimental/functional: Include in diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 54882d797e2..4add1186923 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -238,9 +238,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } /// Store a copy of @p __rhs as the contained object. - template - enable_if_t<__and_<__not_>>, - is_copy_constructible<_ValueType>>::value, any&> + template> + enable_if_t::value, any&> operator=(_ValueType&& __rhs) { *this = any(std::forward<_ValueType>(__rhs)); diff --git a/libstdc++-v3/testsuite/20_util/any/requirements.cc b/libstdc++-v3/testsuite/20_util/any/requirements.cc index 67e4253c557..f33cd67ffe6 100644 --- a/libstdc++-v3/testsuite/20_util/any/requirements.cc +++ b/libstdc++-v3/testsuite/20_util/any/requirements.cc @@ -30,4 +30,7 @@ static_assert(std::is_assignable::value); static_assert(!std::is_assignable>::value); static_assert(std::is_constructible::value); static_assert(!std::is_constructible>::value); - +static_assert(!std::is_assignable&>::value); +static_assert(!std::is_constructible&>::value); +static_assert(!std::is_assignable&>::value); +static_assert(!std::is_constructible&>::value);