svn commit: r315915 - in stable: 10/contrib/libc++/include 9/contrib/libc++/include
Dimitry Andric
dim at FreeBSD.org
Fri Mar 24 18:28:15 UTC 2017
Author: dim
Date: Fri Mar 24 18:28:13 2017
New Revision: 315915
URL: https://svnweb.freebsd.org/changeset/base/315915
Log:
Pull in r283944 from upstream libc++ trunk (by Eric Fiselier):
Fix std::pair on FreeBSD
Summary:
FreeBSD ships an old ABI for std::pair which requires that it have
non-trivial copy/move constructors. Currently the non-trivial
copy/move is achieved by providing explicit definitions of the
constructors. This is problematic because it means the constructors
don't SFINAE properly. In order to SFINAE copy/move constructors they
have to be explicitly defaulted and hense non-trivial.
This patch attempts to provide SFINAE'ing copy/move constructors for
std::pair while still making them non-trivial. It does this by adding
a base class with a non-trivial copy constructor and then allowing
pair's constructors to be generated by the compiler. This also allows
the constructors to be constexpr.
Reviewers: emaste, theraven, rsmith, dim
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25389
This should fix building www/chromium 57.0.2987.110 on stable/10 and
stable/9 without having to use -D_LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1 (which
changes the ABI). Direct commit to stable/10 and stable/9, since head
already has libc++ 4.0, which includes this fix.
Modified:
stable/10/contrib/libc++/include/utility
Changes in other areas also in this revision:
Modified:
stable/9/contrib/libc++/include/utility
Modified: stable/10/contrib/libc++/include/utility
==============================================================================
--- stable/10/contrib/libc++/include/utility Fri Mar 24 17:34:55 2017 (r315914)
+++ stable/10/contrib/libc++/include/utility Fri Mar 24 18:28:13 2017 (r315915)
@@ -244,8 +244,20 @@ extern const piecewise_construct_t piece
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
#endif
+#if !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+struct __non_trivially_copyable_base {
+ _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+ __non_trivially_copyable_base() _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+ __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
+};
+#endif
+
template <class _T1, class _T2>
struct _LIBCPP_TYPE_VIS_ONLY pair
+#if !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+: private __non_trivially_copyable_base
+#endif
{
typedef _T1 first_type;
typedef _T2 second_type;
@@ -253,9 +265,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
_T1 first;
_T2 second;
- // pair(const pair&) = default;
- // pair(pair&&) = default;
-
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -272,18 +281,11 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
)
: first(__p.first), second(__p.second) {}
-#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
- _LIBCPP_INLINE_VISIBILITY
- pair(const pair& __p) = default;
-#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
- _LIBCPP_INLINE_VISIBILITY
- pair(const pair& __p)
- _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
- is_nothrow_copy_constructible<second_type>::value)
- : first(__p.first),
- second(__p.second)
- {
- }
+#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS)
+ pair(pair const&) = default;
+ pair(pair&&) = default;
+#else
+ // Use the implicitly declared copy constructor in C++03
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -315,19 +317,6 @@ struct _LIBCPP_TYPE_VIS_ONLY pair
: first(_VSTD::forward<_U1>(__p.first)),
second(_VSTD::forward<_U2>(__p.second)) {}
-#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
- _LIBCPP_INLINE_VISIBILITY
- pair(pair&& __p) = default;
-#else
- _LIBCPP_INLINE_VISIBILITY
- pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
- is_nothrow_move_constructible<second_type>::value)
- : first(_VSTD::forward<first_type>(__p.first)),
- second(_VSTD::forward<second_type>(__p.second))
- {
- }
-#endif
-
_LIBCPP_INLINE_VISIBILITY
pair&
operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
More information about the svn-src-stable
mailing list