From 65173fee3433747b7b29a9f067070bc8d80d3ebf Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 14 Nov 2013 22:52:25 +0000 Subject: [PATCH] This is a followup to r194536, which changed the pair copy constructor to be trivial in C++03, thus making it trivial in both C++03 and C++11. This patch allows one to opt-in/out of this decision with a macro. You can choose to have the pair copy constructor always be trivial, or always be non-trivial. The flag controlling this is now _LIBCPP_TRIVIAL_PAIR_COPY_CTOR. The client can define this flag to 1, and the pair copy constructor will be trivial (when possible of course), or to 0, and the pair copy constructor will be nontrivial. Default settings for this flag are set in <__config> (as usual). With this commit the default is _LIBCPP_TRIVIAL_PAIR_COPY_CTOR=1 for all platforms except __APPLE__, which defaults to _LIBCPP_TRIVIAL_PAIR_COPY_CTOR=0. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@194742 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 10 ++++++++++ include/utility | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/__config b/include/__config index 43fbf87d..aa8bc448 100644 --- a/include/__config +++ b/include/__config @@ -567,6 +567,16 @@ template struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif +#if defined(__APPLE__) +#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 0 +#endif +#endif + +#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR +# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1 +#endif + #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 diff --git a/include/utility b/include/utility index 303dd4e1..2c1f62cc 100644 --- a/include/utility +++ b/include/utility @@ -272,10 +272,10 @@ struct _LIBCPP_TYPE_VIS_ONLY pair ) : first(__p.first), second(__p.second) {} -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#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) // default the copy ctor in C++03 +#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR _LIBCPP_INLINE_VISIBILITY pair(const pair& __p) _NOEXCEPT_(is_nothrow_copy_constructible::value &&