Home | Libraries | People | FAQ | More |
boost::xpressive::reference — reference<>
is a lazy wrapper for a reference that can be used in xpressive semantic actions.
// In header: <boost/xpressive/xpressive_fwd.hpp> template<typename T> struct reference : public proto::extends< proto::terminal< reference_wrapper< T > >::type, reference< T > > { // construct/copy/destruct explicit reference(T &); // public member functions T & get() const; };
Here is an example of how to use reference<>
to create a lazy reference to an existing object so it can be read and written in an xpressive semantic action.
using namespace boost::xpressive; std::map<std::string, int> result; reference<std::map<std::string, int> > result_ref(result); // Match a word and an integer, separated by =>, // and then stuff the result into a std::map<> sregex pair = ( (s1= +_w) >> "=>" >> (s2= +_d) ) [ result_ref[s1] = as<int>(s2) ];