Type that will own rvalues, reference lvalues. More...
#include <Binding.h>
Public Types | |
using | type = std::conditional_t< std::is_rvalue_reference< T && >::value||std::is_fundamental< std::decay_t< T >>::value, std::decay_t< T >, const T & > |
Public Member Functions | |
constexpr | Binding (T &&t) noexcept |
Data Fields | |
type | value |
Type that will own rvalues, reference lvalues.
T | Type to conditionally bind |
In some situations, templated arguments need to be owned by the recipient. For instance, if you want to create a new range from some container, the handling of whether the container being modified is owned by the new range is very important to avoid both extraneous copies and dangling references.
We have to differentiate between rvalue and lvalue reference arguments to the adaptor constructor. Any rvalues have to be owned by the range being constructed, while any lvalues should be bound to a (const) reference.
This class makes handling that stuff a little easier by providing a single constructor that takes care of all cases.
You can also just use this class as a metafunction (see type).