Greatly scale back ambitions of emulating move semantics in C++03 mode. It was causing more problems than it solved. This fixes http://llvm.org/bugs/show_bug.cgi?id=12704.

llvm-svn: 155918
This commit is contained in:
Howard Hinnant 2012-05-01 15:37:54 +00:00
parent c4b3ad8195
commit bff1bfc6be
2 changed files with 43 additions and 126 deletions

View File

@ -1685,39 +1685,21 @@ public:
::new((void*)__p) _Tp(); ::new((void*)__p) _Tp();
} }
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0> template <class _A0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
typename enable_if void
<
!is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, _A0& __a0) construct(pointer __p, _A0& __a0)
{ {
::new((void*)__p) _Tp(__a0); ::new((void*)__p) _Tp(__a0);
} }
template <class _A0> template <class _A0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
typename enable_if void
<
!is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, const _A0& __a0) construct(pointer __p, const _A0& __a0)
{ {
::new((void*)__p) _Tp(__a0); ::new((void*)__p) _Tp(__a0);
} }
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, _A0 __a0)
{
::new((void*)__p) _Tp(_VSTD::move(__a0));
}
# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0, class _A1> template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -1793,39 +1775,21 @@ public:
::new((void*)__p) _Tp(); ::new((void*)__p) _Tp();
} }
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) # if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0> template <class _A0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
typename enable_if void
<
!is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, _A0& __a0) construct(pointer __p, _A0& __a0)
{ {
::new((void*)__p) _Tp(__a0); ::new((void*)__p) _Tp(__a0);
} }
template <class _A0> template <class _A0>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
typename enable_if void
<
!is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, const _A0& __a0) construct(pointer __p, const _A0& __a0)
{ {
::new((void*)__p) _Tp(__a0); ::new((void*)__p) _Tp(__a0);
} }
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_A0, __rv<_A0> >::value,
void
>::type
construct(pointer __p, _A0 __a0)
{
::new((void*)__p) _Tp(_VSTD::move(__a0));
}
# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) # endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0, class _A1> template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@ -3086,6 +3050,18 @@ operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
return !(nullptr < __x); return !(nullptr < __x);
} }
#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp, class _Dp>
inline _LIBCPP_INLINE_VISIBILITY
unique_ptr<_Tp, _Dp>
move(unique_ptr<_Tp, _Dp>& __t)
{
return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t));
}
#endif
template <class _Tp> struct hash; template <class _Tp> struct hash;
// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t // We use murmur2 when size_t is 32 bits, and cityhash64 when size_t

View File

@ -1297,6 +1297,31 @@ forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
move(_Tp& __t)
{
return __t;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
const _Tp&
move(const _Tp& __t)
{
return __t;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
{
return __t;
}
template <class _Tp> template <class _Tp>
class __rv class __rv
{ {
@ -1309,90 +1334,6 @@ public:
explicit __rv(_Trr& __t) : t_(__t) {} explicit __rv(_Trr& __t) : t_(__t) {}
}; };
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_convertible<_Tp, __rv<_Tp> >::value,
_Tp&
>::type
move(_Tp& __t)
{
return __t;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_convertible<_Tp, __rv<_Tp> >::value,
const _Tp&
>::type
move(const _Tp& __t)
{
return __t;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_Tp, __rv<_Tp> >::value,
_Tp
>::type
move(_Tp& __t)
{
return _Tp(__rv<_Tp>(__t));
}
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_convertible<_Tp, __rv<_Tp> >::value,
typename add_lvalue_reference<_Tp>::type
>::type
forward(_Up& __t)
{
return __t;
}
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_convertible<_Tp, __rv<_Tp> >::value,
typename add_lvalue_reference<_Tp>::type
>::type
forward(const _Up& __t)
{
return __t;
}
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_Tp, __rv<_Tp> >::value,
_Tp
>::type
forward(_Up& __t)
{
return _Tp(__rv<_Tp>(__t));
}
template <class _Tp, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_Tp, __rv<_Tp> >::value,
_Tp
>::type
forward(const _Up& __t)
{
return _Tp(__rv<_Tp>(__t));
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp> template <class _Tp>