libfilezilla
Loading...
Searching...
No Matches
forward_like.hpp
Go to the documentation of this file.
1#ifndef LIBFILEZILLA_FORWARD_LIKE_HEADER
2#define LIBFILEZILLA_FORWARD_LIKE_HEADER
3
4#include <type_traits>
5
14
15namespace fz {
16
17namespace detail {
18
20 template <class T, class U>
21 using apply_value_category_t = std::conditional_t<
22 std::is_lvalue_reference_v<T>,
23 std::remove_reference_t<U>&,
24 std::remove_reference_t<U>&&
25 >;
26
27}
28
30template <class T, class U>
31constexpr detail::apply_value_category_t<T, U> forward_like(U && u) noexcept
32{
33 return static_cast<detail::apply_value_category_t<T, U>>(u);
34}
35
36}
37
38#endif // LIBFILEZILLA_FORWARD_LIKE_HEADER
The namespace used by libfilezilla.
Definition apply.hpp:17
constexpr detail::apply_value_category_t< T, U > forward_like(U &&u) noexcept
applies the value category of T to u, so that u can be perfectly forwarded as-if it were of type T.
Definition forward_like.hpp:31