Commit f320e6a0 by Ville Voutilainen Committed by Ville Voutilainen

Do the operator= SFINAE in the return type for optional,

not in the template parameters.
* include/std/optional (operator=(_Up&&)): Move SFINAE
from template parameters to the return type.
(operator=(const optional<_Up>&)): Likewise.
(operator=(optional<_Up>&&)): Likewise.

From-SVN: r241372
parent 88b3e631
2016-10-20 Ville Voutilainen <ville.voutilainen@gmail.com>
Do the operator= SFINAE in the return type for optional,
not in the template parameters.
* include/std/optional (operator=(_Up&&)): Move SFINAE
from template parameters to the return type.
(operator=(const optional<_Up>&)): Likewise.
(operator=(optional<_Up>&&)): Likewise.
2016-10-20 Jonathan Wakely <jwakely@redhat.com> 2016-10-20 Jonathan Wakely <jwakely@redhat.com>
* include/bits/allocator.h: Remove trailing whitespace, tab-indent. * include/bits/allocator.h: Remove trailing whitespace, tab-indent.
......
...@@ -568,15 +568,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -568,15 +568,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
template<typename _Up = _Tp, template<typename _Up = _Tp>
enable_if_t<__and_< enable_if_t<__and_<
__not_<is_same<optional<_Tp>, decay_t<_Up>>>, __not_<is_same<optional<_Tp>, decay_t<_Up>>>,
is_constructible<_Tp, _Up>, is_constructible<_Tp, _Up>,
__not_<__and_<is_scalar<_Tp>, __not_<__and_<is_scalar<_Tp>,
is_same<_Tp, decay_t<_Up>>>>, is_same<_Tp, decay_t<_Up>>>>,
is_assignable<_Tp&, _Up>>::value, is_assignable<_Tp&, _Up>>::value,
bool> = true> optional&>
optional&
operator=(_Up&& __u) operator=(_Up&& __u)
{ {
if (this->_M_is_engaged()) if (this->_M_is_engaged())
...@@ -587,16 +586,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -587,16 +586,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
template<typename _Up, template<typename _Up>
enable_if_t<__and_< enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>, __not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, const _Up&>, is_constructible<_Tp, const _Up&>,
is_assignable<_Tp&, _Up>, is_assignable<_Tp&, _Up>,
__not_<__converts_from_optional<_Tp, _Up>>, __not_<__converts_from_optional<_Tp, _Up>>,
__not_<__assigns_from_optional<_Tp, _Up>> __not_<__assigns_from_optional<_Tp, _Up>>
>::value, >::value,
bool> = true> optional&>
optional&
operator=(const optional<_Up>& __u) operator=(const optional<_Up>& __u)
{ {
if (__u) if (__u)
...@@ -613,16 +611,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -613,16 +611,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this; return *this;
} }
template<typename _Up, template<typename _Up>
enable_if_t<__and_< enable_if_t<__and_<
__not_<is_same<_Tp, _Up>>, __not_<is_same<_Tp, _Up>>,
is_constructible<_Tp, _Up>, is_constructible<_Tp, _Up>,
is_assignable<_Tp&, _Up>, is_assignable<_Tp&, _Up>,
__not_<__converts_from_optional<_Tp, _Up>>, __not_<__converts_from_optional<_Tp, _Up>>,
__not_<__assigns_from_optional<_Tp, _Up>> __not_<__assigns_from_optional<_Tp, _Up>>
>::value, >::value,
bool> = true> optional&>
optional&
operator=(optional<_Up>&& __u) operator=(optional<_Up>&& __u)
{ {
if (__u) if (__u)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment