tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
forward.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_UTILITY_FORWARD_HPP
5#define TETL_UTILITY_FORWARD_HPP
6
7#include <etl/_type_traits/remove_reference.hpp>
8
9namespace etl {
10
11/// \brief Forwards lvalues as either lvalues or as rvalues, depending on T.
12/// When t is a forwarding reference (a function argument that is declared as an
13/// rvalue reference to a cv-unqualified function template parameter), this
14/// overload forwards the argument to another function with the value category
15/// it had when passed to the calling function.
16///
17/// https://en.cppreference.com/w/cpp/utility/forward
18template <typename T>
19constexpr auto forward(remove_reference_t<T>& param) noexcept -> T&&
20{
21 return static_cast<T&&>(param);
22}
23
24template <typename T>
25constexpr auto forward(remove_reference_t<T>&& param) noexcept -> T&&
26{
27 return static_cast<T&&>(param);
28}
29
30} // namespace etl
31
32#endif // TETL_UTILITY_FORWARD_HPP
Definition adjacent_find.hpp:9
constexpr auto forward(remove_reference_t< T > &&param) noexcept -> T &&
Definition forward.hpp:25
constexpr auto forward(remove_reference_t< T > &param) noexcept -> T &&
Forwards lvalues as either lvalues or as rvalues, depending on T. When t is a forwarding reference (a...
Definition forward.hpp:19