Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

Struct _byval

boost::proto::_byval — A unary callable PolymorphicFunctionObject that strips references and boost::reference_wrapper<> from its argument.

Synopsis

struct _byval :  proto::callable {
  template<typename This, typename T> 
  struct result<This(boost::reference_wrapper< T >)> :  result<This(T)> {
  };
  template<typename This, typename T> 
  struct result<This(T &)> :  result<This(T)> {
  };
  template<typename This, typename T> 
  struct result<This(T)> {
    // types
    typedef T type;
  };

  // public member functions
  template<typename T> T operator()(T const &) const;
  template<typename T> 
    T operator()(boost::reference_wrapper< T > const &) const;
};

Description

Example:

proto::terminal<int>::type i = {42};
int j = 67;
int k = proto::when<proto::_, proto::_byval(proto::_state)>()(i, boost::ref(j));
assert( 67 == k );

_byval public member functions

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

    Parameters:

    t

    The object to unref

    Returns:

    t

    Throws:

    Will not throw.
  2. template<typename T> 
      T operator()(boost::reference_wrapper< 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.


PrevUpHomeNext