diff options
Diffstat (limited to 'kernel/lib/libcxx/include/__utility/move.h')
| -rw-r--r-- | kernel/lib/libcxx/include/__utility/move.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/kernel/lib/libcxx/include/__utility/move.h b/kernel/lib/libcxx/include/__utility/move.h new file mode 100644 index 0000000..048eb06 --- /dev/null +++ b/kernel/lib/libcxx/include/__utility/move.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the BastionOS freestanding C++ standard library. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBBASTION_UTILITY_MOVE_H +#define _LIBBASTION_UTILITY_MOVE_H + +#include <__config> +#include <__type_traits/other_transformations.h> + +_LIBBASTION_BEGIN_NAMESPACE_STD + +template<class _Tp> +_LIBBASTION_NODISCARD inline constexpr __remove_reference_t(_Tp)&& move(_Tp&& __t) noexcept { + return static_cast<__remove_reference_t(_Tp)&&>(__t); +} + +template<class _Tp> +_LIBBASTION_NODISCARD inline constexpr _Tp&& forward(__remove_reference_t(_Tp)& __t) noexcept { + return static_cast<_Tp&&>(__t); +} + +template<class _Tp> +_LIBBASTION_NODISCARD inline constexpr _Tp&& forward(__remove_reference_t(_Tp)&& __t) noexcept { + static_assert(!__is_lvalue_reference(_Tp), "cannot forward an rvalue as an lvalue"); + return static_cast<_Tp&&>(__t); +} + +template<class _Tp> +_LIBBASTION_NODISCARD inline constexpr +conditional_t< + !__is_nothrow_constructible(_Tp, __add_rvalue_reference(_Tp)) && + __is_constructible(_Tp, __add_lvalue_reference(const _Tp)), + const _Tp&, + _Tp&&> +move_if_noexcept(_Tp& __x) noexcept { + return std::move(__x); +} + +_LIBBASTION_END_NAMESPACE_STD + +#endif // _LIBBASTION_UTILITY_MOVE_H |
