...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::proto::_byref — A unary callable PolymorphicFunctionObject that wraps its argument
in a boost::reference_wrapper<>
.
// In header: <boost/proto/transform/arg.hpp> struct _byref : proto::callable { // member classes/structs/unions template<typename This, typename T> struct result<This(T &)> { // types typedef boost::reference_wrapper< T > const type; }; template<typename This, typename T> struct result<This(T)> { // types typedef boost::reference_wrapper< T const > const type; }; // public member functions template<typename T> boost::reference_wrapper< T > const operator()(T &) const; template<typename T> boost::reference_wrapper< T const > const operator()(T const &) const; };
Example:
proto::terminal<int>::type i = {42}; boost::reference_wrapper<proto::terminal<int>::type> j = proto::when<proto::_, proto::_byref(_)>()(i); assert( boost::addressof(i) == boost::addressof(j.get()) );
_byref
public member functionstemplate<typename T> boost::reference_wrapper< T > const operator()(T & t) const;
Wrap the parameter t
in a
boost::reference_wrapper<>
Parameters: |
|
||
Returns: |
|
||
Throws: |
Will not throw. |
template<typename T> boost::reference_wrapper< T const > const operator()(T const & t) const;
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.