diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2016-11-15 14:33:09 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2016-11-15 14:33:09 +0000 |
commit | 8b99f005cbf2fdc6968d75a13cd2c166795418b7 (patch) | |
tree | 3676a43416e28a113de8057900d835998c972dbb /libstdc++-v3/include | |
parent | b229ab2a712ccd44126bcbcaed2da8b998e7366c (diff) | |
download | gcc-8b99f005cbf2fdc6968d75a13cd2c166795418b7.tar.gz |
Constrain swap overload for std::optional (LWG 2748)
* doc/xml/manual/intro.xml: Document LWG 2748 status.
* include/std/optional (optional<T>::swap): Use is_nothrow_swappable_v
for exception specification.
(swap(optional<T>&, optional<T>&)): Disable when T is not swappable.
* testsuite/20_util/optional/swap/2.cc: New test.
From-SVN: r242415
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/std/optional | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index ac73ea75bae..ea673cc6e8b 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -613,7 +613,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void swap(optional& __other) noexcept(is_nothrow_move_constructible<_Tp>() - && noexcept(swap(declval<_Tp&>(), declval<_Tp&>()))) + && is_nothrow_swappable_v<_Tp>) { using std::swap; @@ -920,8 +920,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return !__rhs || __lhs >= *__rhs; } // Swap and creation functions. + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2748. swappable traits for optionals template<typename _Tp> - inline void + inline enable_if_t<is_move_constructible_v<_Tp> && is_swappable_v<_Tp>> swap(optional<_Tp>& __lhs, optional<_Tp>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } |