From 6581b14bdfe9e2c1cd1a6f205def403f6d8ea92f Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 30 Oct 2009 02:29:14 +0000 Subject: [PATCH] PR libstdc++/40925 (again) 2009-10-29 Paolo Carlini Douglas Gregor PR libstdc++/40925 (again) * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, const _T2&), pair<_T1, _T2>::pair(const _T1&, _U2&&)): Add, to deal correctly with move-only types in the presence of "null pointers". * testsuite/20_util/pair/40925.cc: Extend. Co-Authored-By: Douglas Gregor From-SVN: r153733 --- libstdc++-v3/ChangeLog | 9 +++++++++ libstdc++-v3/include/bits/stl_pair.h | 21 +++++++++++++++++---- libstdc++-v3/testsuite/20_util/pair/40925.cc | 21 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2929d5a..402d7fb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,13 @@ 2009-10-29 Paolo Carlini + Douglas Gregor + + PR libstdc++/40925 (again) + * include/bits/stl_pair.h (pair<_T1, _T2>::pair(_U1&&, const _T2&), + pair<_T1, _T2>::pair(const _T1&, _U2&&)): Add, to deal correctly + with move-only types in the presence of "null pointers". + * testsuite/20_util/pair/40925.cc: Extend. + +2009-10-29 Paolo Carlini * include/std/type_traits (__is_int_or_cref): Remove. (__is_convertible_helper): Fix per C++0x and simplify (the hack to diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 0e153d3..4a9fb6b 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -88,10 +88,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : first(__a), second(__b) { } #ifdef __GXX_EXPERIMENTAL_CXX0X__ - template - pair(_U1&& __x, _U2&& __y, typename - std::enable_if::value - && std::is_convertible<_U2, _T2>::value>::type* = 0) + // DR 811. + template::value>::type> + pair(_U1&& __x, const _T2& __y) + : first(std::forward<_U1>(__x)), + second(__y) { } + + template::value>::type> + pair(const _T1& __x, _U2&& __y) + : first(__x), + second(std::forward<_U2>(__y)) { } + + template::value + && std::is_convertible<_U2, _T2>::value>::type> + pair(_U1&& __x, _U2&& __y) : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { } diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc index 491235d..6abeb61 100644 --- a/libstdc++-v3/testsuite/20_util/pair/40925.cc +++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -28,6 +28,15 @@ private: X(const X&) = delete; }; +struct move_only +{ + move_only() { } + move_only(move_only&&) { } + +private: + move_only(const move_only&) = delete; +}; + // libstdc++/40925 void test01() { @@ -43,4 +52,16 @@ void test01() std::pair p6(mp, 0); std::pair p7(0, mp); std::pair p8(mp, mp); + + std::pair p9(0, move_only()); + std::pair p10(0, move_only()); + std::pair p11(move_only(), 0); + std::pair p12(move_only(), 0); + + std::pair p13(ip, move_only()); + std::pair p14(mp, move_only()); + std::pair p15(move_only(), ip); + std::pair p16(move_only(), mp); + + std::pair p17(move_only(), move_only()); } -- 2.7.4