diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2016-07-15 10:44:22 +0300 |
---|---|---|
committer | Ville Voutilainen <ville@gcc.gnu.org> | 2016-07-15 10:44:22 +0300 |
commit | 1ec0f76305eae34c9ce6b90d9373dbd5e3ee2701 (patch) | |
tree | a52099646a820f60187ca70836595341b3218020 /libstdc++-v3 | |
parent | 8d4fc2d3d0c8f87bb3e182be1a618a511f8f9465 (diff) | |
download | gcc-1ec0f76305eae34c9ce6b90d9373dbd5e3ee2701.zip gcc-1ec0f76305eae34c9ce6b90d9373dbd5e3ee2701.tar.gz gcc-1ec0f76305eae34c9ce6b90d9373dbd5e3ee2701.tar.bz2 |
Fix the constraints for any's assignment operator template to properly
reject assignment from a non-copyable lvalue.
From-SVN: r238365
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/std/any | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/any/requirements.cc | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6808613..2386300 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2016-07-14 Ville Voutilainen <ville.voutilainen@gmail.com> + + 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 <jwakely@redhat.com> * include/experimental/functional: Include <parallel/algorithm> in diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 54882d7..4add118 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<typename _ValueType> - enable_if_t<__and_<__not_<is_same<any, decay_t<_ValueType>>>, - is_copy_constructible<_ValueType>>::value, any&> + template<typename _ValueType, + typename _Tp = _Decay<_ValueType>> + enable_if_t<is_copy_constructible<_Tp>::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 67e4253..f33cd67 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<any&, int>::value); static_assert(!std::is_assignable<any&, unique_ptr<int>>::value); static_assert(std::is_constructible<any, int>::value); static_assert(!std::is_constructible<any, unique_ptr<int>>::value); - +static_assert(!std::is_assignable<any&, const unique_ptr<int>&>::value); +static_assert(!std::is_constructible<any&, const unique_ptr<int>&>::value); +static_assert(!std::is_assignable<any&, unique_ptr<int>&>::value); +static_assert(!std::is_constructible<any&, unique_ptr<int>&>::value); |