Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -44,6 +44,17 @@ #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE #define _LIBCPP_ABI_VARIADIC_LOCK_GUARD +#elif _LIBCPP_ABI_VERSION == 1 +// Feature macros for disabling pre ABI v1 features. All of these options +// are deprecated. +#if defined(__FreeBSD__) +#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR +#endif +#endif + +#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR +#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ + use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead #endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y @@ -746,10 +757,6 @@ #define _LIBCPP_WCTYPE_IS_MASK #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 Index: include/utility =================================================================== --- include/utility +++ include/utility @@ -285,9 +285,6 @@ _T1 first; _T2 second; - // pair(const pair&) = default; - // pair(pair&&) = default; - #ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS template , _Dummy>::value && @@ -310,10 +307,7 @@ ) : 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 +#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) _LIBCPP_INLINE_VISIBILITY pair(const pair& __p) _NOEXCEPT_(is_nothrow_copy_constructible::value && @@ -322,6 +316,21 @@ second(__p.second) { } + +# ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible::value && + is_nothrow_move_constructible::value) + : first(_VSTD::forward(__p.first)), + second(_VSTD::forward(__p.second)) + { + } +# endif +#elif !defined(_LIBCPP_CXX03_LANG) + pair(pair const&) = default; + pair(pair&&) = default; +#else + // Use the implicitly declared copy constructor in C++03 #endif _LIBCPP_INLINE_VISIBILITY @@ -353,19 +362,6 @@ : 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::value && - is_nothrow_move_constructible::value) - : first(_VSTD::forward(__p.first)), - second(_VSTD::forward(__p.second)) - { - } -#endif - _LIBCPP_INLINE_VISIBILITY pair& operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable::value && Index: test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp =================================================================== --- /dev/null +++ test/libcxx/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// Doesn't pass due to use of is_trivially_* trait. +// XFAIL: gcc-4.9 + +// Test that we properly provide the old non-trivial copy operations +// when the ABI macro is defined. + +#define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR +#include +#include + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +struct Dummy { + Dummy(Dummy const&) = delete; + Dummy(Dummy &&) = default; +}; +#endif + +int main() +{ + typedef std::pair P; + { + static_assert(std::is_copy_constructible

::value, ""); + static_assert(!std::is_trivially_copy_constructible

::value, ""); + } +#if TEST_STD_VER >= 11 + { + static_assert(std::is_move_constructible

::value, ""); + static_assert(!std::is_trivially_move_constructible

::value, ""); + } + { + using P1 = std::pair; + // This line fails because the non-trivial constructors do not provide + // SFINAE. + // static_assert(!std::is_copy_constructible::value, ""); + static_assert(!std::is_trivially_copy_constructible::value, ""); + static_assert(std::is_move_constructible::value, ""); + static_assert(!std::is_trivially_move_constructible::value, ""); + } +#endif +}