Implement forward
This commit is contained in:
parent
01fad9046e
commit
20f552790f
20
util.hpp
Normal file
20
util.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../type/type.hpp"
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline constexpr T &&forward(type::remove_reference_t<T> &t) noexcept
|
||||||
|
{
|
||||||
|
return static_cast<T &&>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline constexpr T &&forward(type::remove_reference_t<T> &&t) noexcept
|
||||||
|
{
|
||||||
|
static_assert(!type::is_lvalue_reference_v<T>, "Can not forward an rvalue as an lvalue.");
|
||||||
|
return static_cast<T &&>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
Loading…
Reference in New Issue
Block a user