libfilezilla
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 
15 namespace fz {
16 
17 namespace 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 
30 template <class T, class U>
31 constexpr 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
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
The namespace used by libfilezilla.
Definition: apply.hpp:17