[v3 PATCH] LWG 2766, LWG 2749
Jonathan Wakely
jwakely@redhat.com
Wed Nov 30 15:08:00 GMT 2016
On 26/11/16 14:47 +0200, Ville Voutilainen wrote:
>Updated patches attached, and tested with the full testsuite on Linux-PPC64.
Both patches are OK for trunk with the minor tweaks noted below.
Thanks.
>diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
>index ef52538..981dbeb 100644
>--- a/libstdc++-v3/include/bits/stl_pair.h
>+++ b/libstdc++-v3/include/bits/stl_pair.h
>@@ -478,6 +478,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
> noexcept(noexcept(__x.swap(__y)))
> { __x.swap(__y); }
>+
>+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
>+ template<typename _T1, typename _T2>
>+ inline
>+ typename enable_if<!__and_<__is_swappable<_T1>,
>+ __is_swappable<_T2>>::value>::type
>+ swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
>+#endif
> #endif // __cplusplus >= 201103L
>
> /**
>diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
>index f9ec60f..21b0bac 100644
>--- a/libstdc++-v3/include/bits/unique_ptr.h
>+++ b/libstdc++-v3/include/bits/unique_ptr.h
>@@ -649,6 +649,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> swap(unique_ptr<_Tp, _Dp>& __x,
> unique_ptr<_Tp, _Dp>& __y) noexcept
> { __x.swap(__y); }
Insert a blank line here please.
>+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
>+ template<typename _Tp, typename _Dp>
>+ inline
>+ typename enable_if<!__is_swappable<_Dp>::value>::type
>+ swap(unique_ptr<_Tp, _Dp>&,
>+ unique_ptr<_Tp, _Dp>&) = delete;
>+#endif
>
> template<typename _Tp, typename _Dp,
> typename _Up, typename _Ep>
>diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
>index 3ab0355..86100b5 100644
>--- a/libstdc++-v3/include/std/array
>+++ b/libstdc++-v3/include/std/array
>@@ -287,6 +287,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
> swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
> noexcept(noexcept(__one.swap(__two)))
> { __one.swap(__two); }
Insert a blank line here please.
>+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
>+ template<typename _Tp, std::size_t _Nm>
>+ inline
>+ typename enable_if<
>+ !_GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value>::type
>+ swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete;
>+#endif
>
> template<std::size_t _Int, typename _Tp, std::size_t _Nm>
> constexpr _Tp&
>diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
>index 63cacd4..8952750 100644
>--- a/libstdc++-v3/include/std/tuple
>+++ b/libstdc++-v3/include/std/tuple
>@@ -1442,17 +1442,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> forward_as_tuple(_Elements&&... __args) noexcept
> { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
>
>- template<typename... _Tps>
>- struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
>- { };
>-
>- // Internal type trait that allows us to sfinae-protect tuple_cat.
>- template<typename _Tp>
>- struct __is_tuple_like
>- : public __is_tuple_like_impl<typename std::remove_cv
>- <typename std::remove_reference<_Tp>::type>::type>::type
>- { };
>-
> template<size_t, typename, typename, size_t>
> struct __make_tuple_impl;
>
>@@ -1596,6 +1585,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
> noexcept(noexcept(__x.swap(__y)))
> { __x.swap(__y); }
Insert a blank line here please.
>+#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
>+ template<typename... _Elements>
>+ inline
>+ typename enable_if<!__and_<__is_swappable<_Elements>...>::value>::type
>+ swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
>+#endif
>
> // A class (and instance) which can be used in 'tie' when an element
> // of a tuple is not required
>diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
>index e5f2bba..49f76cc 100644
>--- a/libstdc++-v3/include/std/type_traits
>+++ b/libstdc++-v3/include/std/type_traits
>@@ -2593,9 +2593,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> template <typename _Tp>
> struct __is_nothrow_swappable;
>
>+ template<typename... _Elements>
>+ class tuple;
>+
>+ template<typename>
>+ struct __is_tuple_like_impl : false_type
>+ { };
>+
>+ template<typename... _Tps>
>+ struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
>+ { };
>+
>+ // Internal type trait that allows us to sfinae-protect tuple_cat.
>+ template<typename _Tp>
>+ struct __is_tuple_like
>+ : public __is_tuple_like_impl<typename std::remove_cv
>+ <typename std::remove_reference<_Tp>::type>::type>::type
We can lose the std:: quals here.
>+ { };
>+
> template<typename _Tp>
> inline
>- typename enable_if<__and_<is_move_constructible<_Tp>,
>+ typename enable_if<__and_<__not_<__is_tuple_like<_Tp>>,
>+ is_move_constructible<_Tp>,
> is_move_assignable<_Tp>>::value>::type
> swap(_Tp&, _Tp&)
> noexcept(__and_<is_nothrow_move_constructible<_Tp>,
More information about the Libstdc++
mailing list