From f54708205aea62af1d136eaa41e78eeed69c7572 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Tue, 14 Apr 2020 12:55:53 +0200 Subject: [PATCH] Implement forward --- util.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 util.hpp diff --git a/util.hpp b/util.hpp new file mode 100644 index 0000000..b389725 --- /dev/null +++ b/util.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "../type/type.hpp" + +namespace util { + +template +inline constexpr T &&forward(type::remove_reference_t &t) noexcept +{ + return static_cast(t); +} + +template +inline constexpr T &&forward(type::remove_reference_t &&t) noexcept +{ + static_assert(!type::is_lvalue_reference_v, "Can not forward an rvalue as an lvalue."); + return static_cast(t); +} + +} // namespace util