boost::proto::_byref — 一个一元可调用对象,是 多态函数对象,它将其参数包装在 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; };
示例
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()) );