Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct _data

boost::proto::_data — A PrimitiveTransform that returns the current data unmodified. If the data (third) parameter is a transform environment, it returns the value associated with the proto::data_type key. Otherwise, it returns the data parameter unmodified.

Synopsis

// In header: <boost/proto/transform/arg.hpp>


struct _data :  proto::transform< _data > {
  // member classes/structs/unions
  template<typename Expr, typename State, typename Data> 
  struct impl :  
    mpl::if_c<
      proto::is_env<Data>::value,
      proto::_env_var<proto::data_type>,
      proto::_env
    >::type::template impl<Expr, State, Data>
  {
  };
};

Description

If the data (third) parameter is a transform environment, it returns the value associated with the proto::data_type key. Otherwise, it returns the data parameter unmodified.

Example:

proto::terminal<int>::type i = {42};
std::string str("hello");
std::string & d1 = proto::_data()(i, 'a', str);
assert( &str == &d1 );

std::string & d2 = proto::_data()(i, 'a', (proto::data = boost::ref(str)));
assert( &str == &d2 );


PrevUpHomeNext