| Home | Libraries | People | FAQ | More

## Struct _byref

boost::proto::_byref — A unary callable PolymorphicFunctionObject that wraps its argument in a `boost::reference_wrapper<>`.

## Synopsis

    // 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;
    };

## Description

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 functions

1.     template<typename T>
         boost::reference_wrapper< T > const operator()(T & t) const;

   Wrap the parameter `t` in a `boost::reference_wrapper<>`

   Parameters: |
   `t` | The object to wrap
   Returns: | `boost::ref(t)`
   Throws: | Will not throw.

2.     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.