| Home | Libraries | People | FAQ | More

## Struct template reference

boost::xpressive::reference — `reference<>` is a lazy wrapper for a reference that can be used in xpressive semantic actions.

## Synopsis

    // In header: <boost/xpressive/regex_actions.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;
    };

## Description

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) ];

### Template Parameters

1.     typename T

   The type of the referent.

### `reference` public construct/copy/destruct

1.     explicit reference(T & t);

   Store a reference to `t`.

   Parameters:

   `t` | Reference to object

### `reference` public member functions

1.     T & get() const;

   Fetch the stored value.