From 3c0d80179c0f2053fb2b892ee9af47200cb5d539 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Fri, 29 Mar 2024 00:18:28 +0100 Subject: Separate the std-lite stuff --- deimos/core/std.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 deimos/core/std.h (limited to 'deimos/core/std.h') diff --git a/deimos/core/std.h b/deimos/core/std.h new file mode 100644 index 0000000..1c611cd --- /dev/null +++ b/deimos/core/std.h @@ -0,0 +1,49 @@ +#pragma once + +namespace std +{ + +template constexpr bool _is_same_helper = false; +template constexpr bool _is_same_helper = true; +template concept same_as = _is_same_helper && _is_same_helper; + +template struct remove_reference { using type = T; }; +template struct remove_reference { using type = T; }; +template struct remove_reference { using type = T; }; +template using remove_reference_t = remove_reference::type; + +template +constexpr remove_reference_t&& move(T&& r) noexcept +{ + return static_cast&&>(r); +} + +template +constexpr T&& forward(remove_reference_t& r) noexcept +{ + return static_cast(r); +} + +template +constexpr T&& forward(remove_reference_t&& r) noexcept // NOLINT +{ + return static_cast(r); +} + +template +constexpr T exchange(T& obj, U&& new_value) +{ + T old_value = std::move(obj); + obj = std::forward(new_value); + return old_value; +} + +} // namespace std + +static_assert(std::same_as, ""); +static_assert(!std::same_as, ""); + +static_assert(std::same_as, int>, ""); +static_assert(std::same_as, int>, ""); +static_assert(std::same_as, int>, ""); + -- cgit