| Home | Libraries | People | FAQ | More

## Struct template sub_match

boost::xpressive::sub_match — Class template sub_match denotes the sequence of characters matched by a particular marked sub-expression.

## Synopsis

    template<typename BidiIter>
    struct sub_match : public std::pair< BidiIter, BidiIter > {
      // types
      typedef iterator_value< BidiIter >::type      value_type;
      typedef iterator_difference< BidiIter >::type difference_type;
      typedef std::basic_string< value_type >       string_type;
      typedef BidiIter                              iterator;

      // construct/copy/destruct
      sub_match(BidiIter = BidiIter(), BidiIter = BidiIter(), bool = false);

      // public member functions
      string_type str() const;
      operator string_type() const;
      difference_type length() const;
      operator bool_type() const;
      bool operator!() const;
      int compare(string_type const &) const;
      int compare(sub_match const &) const;
      int compare(value_type const *) const;

      bool matched;
    };

## Description

When the marked sub-expression denoted by an object of type sub_match<> participated in a regular expression match then member matched evaluates to true, and members first and second denote the range of characters [first,second) which formed that match. Otherwise matched is false, and members first and second contained undefined values.

If an object of type sub_match<> represents sub-expression 0 - that is to say the whole match - then member matched is always true, unless a partial match was obtained as a result of the flag match_partial being passed to a regular expression algorithm, in which case member matched is false, and members first and second represent the character range that formed the partial match.

### `sub_match` construct/copy/destruct

1.     sub_match(BidiIter first = BidiIter(), BidiIter second = BidiIter(),
                 bool matched_ = false);

### `sub_match` public member functions

1.     string_type str() const;

2.     operator string_type() const;

3.     difference_type length() const;

4.     operator bool_type() const;

5.     bool operator!() const;

6.     int compare(string_type const & str) const;

   Parameters: |

   `str` | the string against which to compare

   Returns: | the results of (*this).str().compare(str)

7.     int compare(sub_match const & sub) const;

   This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

8.     int compare(value_type const * ptr) const;

   This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

| Copyright © 2003, 2004 Eric Niebler