###

# Boost.Regex

## sub_match

###

### Synopsis

#include <boost/regex.hpp>

Regular expressions are different from many simple pattern-matching algorithms in that as well as finding an overall match they can also produce sub-expression matches: each sub-expression being delimited in the pattern by a pair of parenthesis (...). There has to be some method for reporting sub-expression matches back to the user: this is achieved this by defining a class match_results that acts as an indexed collection of sub-expression matches, each sub-expression match being contained in an object of type sub_match .

Objects of type sub_match may only obtained by subscripting an object of type match_results .

Objects of type sub_match may be compared to objects of type std::basic_string, or const charT* or const charT .

Objects of type sub_match may be added to objects of type std::basic_string, or const charT* or const charT, to produce a new std::basic_string object.

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.

When the marked sub-expression denoted by an object of type sub_match<> was repeated, then the sub_match object represents the match obtained by the last repeat. The complete set of all the captures obtained for all the repeats, may be accessed via the captures() member function (Note: this has serious performance implications, you have to explicitly enable this feature).

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.

    namespace boost{

    template <class BidirectionalIterator>
    class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
    {
    public:
       typedef typename iterator_traits<BidirectionalIterator>::value_type       value_type;
       typedef typename iterator_traits<BidirectionalIterator>::difference_type  difference_type;
       typedef          BidirectionalIterator                                    iterator;

       bool matched;

       difference_type length()const;
       operator basic_string<value_type>()const;
       basic_string<value_type> str()const;

       int compare(const sub_match& s)const;
       int compare(const basic_string<value_type>& s)const;
       int compare(const value_type* s)const;
    #ifdef BOOST_REGEX_MATCH_EXTRA
       typedef implementation-private capture_sequence_type;
       const capture_sequence_type& captures()const;
    #endif
    };
    //
    // comparisons to another sub_match:
    //
    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

    //
    // comparisons to a basic_string:
    //
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);
    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

    //
    // comparisons to a pointer to a character array:
    //
    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

    //
    // comparisons to a single character:
    //
    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                     const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);
    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);
    //
    // addition operators:
    //
    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
        operator + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
                    const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
        operator + (const sub_match<BidirectionalIterator>& m,
                    const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s);
    template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
                    const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m,
                    typename iterator_traits<BidirectionalIterator>::value_type const * s);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
                    const sub_match<BidirectionalIterator>& m);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m,
                    typename iterator_traits<BidirectionalIterator>::value_type const& s);
    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m1,
                    const sub_match<BidirectionalIterator>& m2);

    //
    // stream inserter:
    //
    template <class charT, class traits, class BidirectionalIterator>
    basic_ostream<charT, traits>&
       operator << (basic_ostream<charT, traits>& os,
                    const sub_match<BidirectionalIterator>& m);

    } // namespace boost

### Description

#### sub_match members

    typedef typename std::iterator_traits<iterator>::value_type value_type;

The type pointed to by the iterators.

    typedef typename std::iterator_traits<iterator>::difference_type difference_type;

A type that represents the difference between two iterators.

    typedef iterator iterator_type;

The iterator type.

    iterator first

An iterator denoting the position of the start of the match.

    iterator second

An iterator denoting the position of the end of the match.

    bool matched

A Boolean value denoting whether this sub-expression participated in the match.

    static difference_type length();

Effects: returns the length of this matched sub-expression, or 0 if this sub-expression was not matched: `matched ? distance(first, second) : 0)`.

    operator basic_string<value_type>()const;

Effects: converts *this into a string: returns `(matched ? basic_string<value_type>(first, second) : basic_string<value_type>()).`

    basic_string<value_type> str()const;

Effects: returns a string representation of *this: `(matched ? basic_string<value_type>(first, second) : basic_string<value_type>())`.

    int compare(const sub_match& s)const;

Effects: performs a lexical comparison to s: returns `str().compare(s.str())`.

    int compare(const basic_string<value_type>& s)const;

Effects: compares *this to the string s: returns `str().compare(s)`.

    int compare(const value_type* s)const;

Effects: compares *this to the null-terminated string s: returns `str().compare(s)`.

    typedef implementation-private capture_sequence_type;

Defines an implementation-specific type that satisfies the requirements of a standard library Sequence (21.1.1 including the optional Table 68 operations), whose value_type is a sub_match<BidirectionalIterator>. This type happens to be std::vector<sub_match<BidirectionalIterator> >, but you shouldn't actually rely on that.

    const capture_sequence_type& captures()const;

Effects: returns a sequence containing all the captures obtained for this sub-expression.

Preconditions: the library must be built and used with BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag match_extra to the regex matching functions (regex_match, regex_search, regex_iterator or regex_token_iterator) in order for this member function to be defined and return useful information.

Rationale: Enabling this feature has several consequences:

- sub_match occupies more memory resulting in complex expressions running out of memory or stack space more quickly during matching.
- The matching algorithms are less efficient at handling some features (independent sub-expressions for example), even when match_extra is not used.
- The matching algorithms are much less efficient (i.e. slower), when match_extra is used. Mostly this is down to the extra memory allocations that have to take place.

#### sub_match non-member operators

##### Comparisons against self

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) == 0`.

    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) != 0`.

    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) < 0`.

    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) <= 0`.

    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) >= 0`.

    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs.compare(rhs) > 0`.

##### Comparisons with std::basic_string

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits,
                      Allocator>& lhs, const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs == rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs != rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs < rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs > rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs >= rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs <= rhs.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() == rhs`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() != rhs`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() < rhs`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() > rhs`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() >= rhs`.

    template <class BidirectionalIterator, class traits, class Allocator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      const std::basic_string<iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& rhs);

Effects: returns `lhs.str() <= rhs`.

##### Comparisons with null-terminated strings

    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs == rhs.str()`.

    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs != rhs.str()`.

    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs < rhs.str()`.

    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs > rhs.str()`.

    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs >= rhs.str()`.

    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs <= rhs.str()`.

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() == rhs`.

    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() != rhs`.

    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() < rhs`.

    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() > rhs`.

    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() >= rhs`.

    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const* rhs);

Effects: returns `lhs.str() <= rhs`.

##### Comparisons with a single character

    template <class BidirectionalIterator>
    bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs == rhs.str()`.

    template <class BidirectionalIterator>
    bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs != rhs.str()`.

    template <class BidirectionalIterator>
    bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs < rhs.str()`.

    template <class BidirectionalIterator>
    bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                     const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs > rhs.str()`.

    template <class BidirectionalIterator>
    bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs >= rhs.str()`.

    template <class BidirectionalIterator>
    bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
                      const sub_match<BidirectionalIterator>& rhs);

Effects: returns `lhs <= rhs.str()`.

    template <class BidirectionalIterator>
    bool operator == (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() == rhs`.

    template <class BidirectionalIterator>
    bool operator != (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() != rhs`.

    template <class BidirectionalIterator>
    bool operator < (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() < rhs`.

    template <class BidirectionalIterator>
    bool operator > (const sub_match<BidirectionalIterator>& lhs,
                     typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() > rhs`.

    template <class BidirectionalIterator>
    bool operator >= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() >= rhs`.

    template <class BidirectionalIterator>
    bool operator <= (const sub_match<BidirectionalIterator>& lhs,
                      typename iterator_traits<BidirectionalIterator>::value_type const& rhs);

Effects: returns `lhs.str() <= rhs`.

##### Addition operators

The addition operators for sub_match allow you to add a sub_match to any type to which you can add a std::string and obtain a new string as the result.

    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
        operator + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
                    const sub_match<BidirectionalIterator>& m);

Effects: returns `s + m.str()`.

    template <class BidirectionalIterator, class traits, class Allocator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
        operator + (const sub_match<BidirectionalIterator>& m,
                    const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s);

Effects: returns `m.str() + s`.

    template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
                    const sub_match<BidirectionalIterator>& m);

Effects: returns `s + m.str()`.

    template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m,
                    typename iterator_traits<BidirectionalIterator>::value_type const * s);

Effects: returns `m.str() + s`.

    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
                    const sub_match<BidirectionalIterator>& m);

Effects: returns `s + m.str()`.

    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m,
                    typename iterator_traits<BidirectionalIterator>::value_type const& s);

Effects: returns `m.str() + s`.

    template <class BidirectionalIterator>
    std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
        operator + (const sub_match<BidirectionalIterator>& m1,
                    const sub_match<BidirectionalIterator>& m2);

Effects: returns `m1.str() + m2.str()`.

##### Stream inserter

    template <class charT, class traits, class BidirectionalIterator>
    basic_ostream<charT, traits>&
       operator << (basic_ostream<charT, traits>& os
                    const sub_match<BidirectionalIterator>& m);

Effects: returns `(os << m.str())`.

Revised 24 Oct 2003

© Copyright John Maddock 1998- 2003

Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)