Commit 6581b14b by Paolo Carlini Committed by Paolo Carlini

PR libstdc++/40925 (again)

2009-10-29  Paolo Carlini  <paolo.carlini@oracle.com>
  	    Douglas Gregor  <doug.gregor@gmail.com>

	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 <doug.gregor@gmail.com>

From-SVN: r153733
parent a684a364
2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com>
Douglas Gregor <doug.gregor@gmail.com>
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 <paolo.carlini@oracle.com>
* include/std/type_traits (__is_int_or_cref): Remove. * include/std/type_traits (__is_int_or_cref): Remove.
(__is_convertible_helper): Fix per C++0x and simplify (the hack to (__is_convertible_helper): Fix per C++0x and simplify (the hack to
......
...@@ -88,10 +88,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -88,10 +88,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: first(__a), second(__b) { } : first(__a), second(__b) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
template<class _U1, class _U2> // DR 811.
pair(_U1&& __x, _U2&& __y, typename template<class _U1, class = typename
std::enable_if<std::is_convertible<_U1, _T1>::value std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
&& std::is_convertible<_U2, _T2>::value>::type* = 0) pair(_U1&& __x, const _T2& __y)
: first(std::forward<_U1>(__x)),
second(__y) { }
template<class _U2, class = typename
std::enable_if<std::is_convertible<_U2, _T2>::value>::type>
pair(const _T1& __x, _U2&& __y)
: first(__x),
second(std::forward<_U2>(__y)) { }
template<class _U1, class _U2, class = typename
std::enable_if<std::is_convertible<_U1, _T1>::value
&& std::is_convertible<_U2, _T2>::value>::type>
pair(_U1&& __x, _U2&& __y)
: first(std::forward<_U1>(__x)), : first(std::forward<_U1>(__x)),
second(std::forward<_U2>(__y)) { } second(std::forward<_U2>(__y)) { }
......
...@@ -28,6 +28,15 @@ private: ...@@ -28,6 +28,15 @@ private:
X(const X&) = delete; X(const X&) = delete;
}; };
struct move_only
{
move_only() { }
move_only(move_only&&) { }
private:
move_only(const move_only&) = delete;
};
// libstdc++/40925 // libstdc++/40925
void test01() void test01()
{ {
...@@ -43,4 +52,16 @@ void test01() ...@@ -43,4 +52,16 @@ void test01()
std::pair<int X::*, int X::*> p6(mp, 0); std::pair<int X::*, int X::*> p6(mp, 0);
std::pair<int X::*, int X::*> p7(0, mp); std::pair<int X::*, int X::*> p7(0, mp);
std::pair<int X::*, int X::*> p8(mp, mp); std::pair<int X::*, int X::*> p8(mp, mp);
std::pair<int*, move_only> p9(0, move_only());
std::pair<int X::*, move_only> p10(0, move_only());
std::pair<move_only, int*> p11(move_only(), 0);
std::pair<move_only, int X::*> p12(move_only(), 0);
std::pair<int*, move_only> p13(ip, move_only());
std::pair<int X::*, move_only> p14(mp, move_only());
std::pair<move_only, int*> p15(move_only(), ip);
std::pair<move_only, int X::*> p16(move_only(), mp);
std::pair<move_only, move_only> p17(move_only(), move_only());
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment