libfilezilla
Loading...
Searching...
No Matches
forward_like.hpp File Reference

A function that acts like std::forward, but applies the value category of its first template parameter. More...

#include <type_traits>
Include dependency graph for forward_like.hpp:

Go to the source code of this file.

Namespaces

namespace  fz
 The namespace used by libfilezilla.
 

Functions

template<class T , class U >
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.
 

Detailed Description

A function that acts like std::forward, but applies the value category of its first template parameter.

It can be used, for instance, to perfect forward the member of a struct according to the value category of the object that is the instance of that struct.

Inspired by Vittorio Romeo's proposal: https://vittorioromeo.info/Misc/fwdlike.html