![]() |
Home | Libraries | People | FAQ | More |
boost::forward_like
// In header: <boost/move/utility_core.hpp> template<typename T> output_reference forward_like(input_reference);
Forwards x (usually a member or a base of an object of type T) with the value category of T, as C++23 std::forward_like: the result is an lvalue if T is an lvalue reference, otherwise an rvalue. The result is const if x is const or if remove_reference<T>::type is const.
Typical use, where T is the template parameter of a forwarding reference: template<class T> void f(BOOST_FWD_REF(T) t) { g(boost::forward_like<T>(t.member)); }
Note: as std::forward_like, the category of the object x refers to is changed: if x is a reference member, the object it refers to is forwarded as an rvalue.
Note: in C++03 compilers, BOOST_FWD_REF(T) binds the argument to a const reference, so a member declared const can not be detected: if T is ::boost::rv
(a moved argument), the member is moved, also if it is declared const. Do not use forward_like on const members in C++03 code (C++11 compilers copy them).