Make std::forward and std::move (and std::move_if_noexcept) constexpr in C++14
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@186344 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e1d05121d
commit
01a0e90783
@ -843,7 +843,7 @@ template <class _T1, class... _Args>
|
|||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
|
constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
|
||||||
{
|
{
|
||||||
return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move<tuple<_Args...>>(__tup));
|
return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1466,7 +1466,7 @@ struct is_destructible
|
|||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||||
typename remove_reference<_Tp>::type&&
|
typename remove_reference<_Tp>::type&&
|
||||||
move(_Tp&& __t) _NOEXCEPT
|
move(_Tp&& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
@ -1475,7 +1475,7 @@ move(_Tp&& __t) _NOEXCEPT
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||||
_Tp&&
|
_Tp&&
|
||||||
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
@ -1483,7 +1483,7 @@ forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||||
_Tp&&
|
_Tp&&
|
||||||
forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
|
forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
|
||||||
{
|
{
|
||||||
|
@ -38,10 +38,10 @@ template <class T, size_t N>
|
|||||||
void
|
void
|
||||||
swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
|
swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
|
||||||
|
|
||||||
template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept;
|
template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
|
||||||
template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept;
|
template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
|
||||||
|
|
||||||
template <class T> typename remove_reference<T>::type&& move(T&&) noexcept;
|
template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
typename conditional
|
typename conditional
|
||||||
@ -50,7 +50,7 @@ template <class T>
|
|||||||
const T&,
|
const T&,
|
||||||
T&&
|
T&&
|
||||||
>::type
|
>::type
|
||||||
move_if_noexcept(T& x) noexcept;
|
move_if_noexcept(T& x) noexcept; // constexpr in C++14
|
||||||
|
|
||||||
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::v
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp>
|
template <class _Tp>
|
||||||
inline _LIBCPP_INLINE_VISIBILITY
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
typename conditional
|
typename conditional
|
||||||
<
|
<
|
||||||
|
@ -70,4 +70,11 @@ int main()
|
|||||||
static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
|
static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
|
||||||
static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
|
static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
|
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
constexpr int i1 = std::move(23);
|
||||||
|
static_assert(i1 == 23, "" );
|
||||||
|
constexpr int i2 = std::forward<int>(42);
|
||||||
|
static_assert(i2 == 42, "" );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,10 @@ int main()
|
|||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||||
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
|
||||||
|
|
||||||
|
#if _LIBCPP_STD_VER > 11
|
||||||
|
constexpr int i1 = 23;
|
||||||
|
constexpr int i2 = std::move_if_noexcept(i1);
|
||||||
|
static_assert(i2 == 23, "" );
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user