Some more stdlib (array and vector, untested so far).

This commit is contained in:
2024-01-12 00:13:45 +01:00
parent 164f05bd59
commit ff3214fa5a
23 changed files with 577 additions and 9 deletions

40
stdlib/include/utility Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#if !defined(BAD_APPLE_OS_UTILITY_INCLUDED)
#define BAD_APPLE_OS_UTILITY_INCLUDED
#include "type_traits"
namespace std
{
template<typename T>
constexpr remove_reference_t<T>&& move(T&& val) noexcept
{
return static_cast<remove_reference_t<T>&&>(val);
}
template<typename T>
constexpr void swap(T& first, T& second)
{
T temp = std::move(first);
first = std::move(second);
second = std::move(temp);
}
template<typename T>
[[nodiscard]] constexpr T&& forward(remove_reference_t<T>& value)
{
return static_cast<T&&>(value);
}
template<typename T, typename U = T>
[[nodiscard]] constexpr T exchange(T& obj, U&& newValue)
{
T oldValue = std::move(obj);
obj = std::forward<U>(newValue);
return oldValue;
}
}
#endif // !defined(BAD_APPLE_OS_UTILITY_INCLUDED)