mirror of git://gcc.gnu.org/git/gcc.git
Fix the constraints for any's assignment operator template to properly
reject assignment from a non-copyable lvalue. From-SVN: r238365
This commit is contained in:
parent
8d4fc2d3d0
commit
1ec0f76305
|
|
@ -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>
|
2016-07-14 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
* include/experimental/functional: Include <parallel/algorithm> in
|
* include/experimental/functional: Include <parallel/algorithm> in
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Store a copy of @p __rhs as the contained object.
|
/// Store a copy of @p __rhs as the contained object.
|
||||||
template<typename _ValueType>
|
template<typename _ValueType,
|
||||||
enable_if_t<__and_<__not_<is_same<any, decay_t<_ValueType>>>,
|
typename _Tp = _Decay<_ValueType>>
|
||||||
is_copy_constructible<_ValueType>>::value, any&>
|
enable_if_t<is_copy_constructible<_Tp>::value, any&>
|
||||||
operator=(_ValueType&& __rhs)
|
operator=(_ValueType&& __rhs)
|
||||||
{
|
{
|
||||||
*this = any(std::forward<_ValueType>(__rhs));
|
*this = any(std::forward<_ValueType>(__rhs));
|
||||||
|
|
|
||||||
|
|
@ -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_assignable<any&, unique_ptr<int>>::value);
|
||||||
static_assert(std::is_constructible<any, int>::value);
|
static_assert(std::is_constructible<any, int>::value);
|
||||||
static_assert(!std::is_constructible<any, unique_ptr<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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue