##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::sub_match::compare

From cppreference.com
< cpp‎ | regex‎ | sub match

Defined in header `<regex>` |  |
Direct comparison |  |
template< class BidirIt > bool operator==( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (1) | (since C++11)
template< class BidirIt > bool operator!=( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (2) | (since C++11)
template< class BidirIt > bool operator<( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (3) | (since C++11)
template< class BidirIt > bool operator<=( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (4) | (since C++11)
template< class BidirIt > bool operator>( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (5) | (since C++11)
template< class BidirIt > bool operator>=( const sub_match<BiIter>& lhs, const sub_match<BidirIt>& rhs ); | (6) | (since C++11)
`std::basic_string` and `std::sub_match` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (7) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (8) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (9) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (10) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (11) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& lhs, const sub_match<BidirIt>& rhs ); | (12) | (since C++11)
`std::sub_match` and `std::basic_string` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (13) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (14) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (15) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (16) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (17) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const sub_match<BidirIt>& lhs, const std::basic_string< typename std::iterator_traits<BidirIt>::value_type, Traits,Alloc>& rhs ); | (18) | (since C++11)
`std::iterator_traits<BiIter>::value_type*` and `std::sub_match` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (19) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (20) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (21) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (22) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (23) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const typename std::iterator_traits<BiIter>::value_type* rhs, const sub_match<BidirIt>& rhs ); | (24) | (since C++11)
`std::sub_match` and `std::iterator_traits<BiIter>::value_type*` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (25) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (26) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (27) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (28) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (29) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type* rhs ); | (30) | (since C++11)
`std::iterator_traits<BiIter>::value_type&` and `std::sub_match` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (31) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (32) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (33) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (34) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (35) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const typename std::iterator_traits<BiIter>::value_type& rhs, const sub_match<BidirIt>& rhs ); | (36) | (since C++11)
`std::sub_match` and `std::iterator_traits<BiIter>::value_type&` |  |
template< class BidirIt, class Traits, class Alloc > bool operator==( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (37) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator!=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (38) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (39) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator<=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (40) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (41) | (since C++11)
template< class BidirIt, class Traits, class Alloc > bool operator>=( const sub_match<BidirIt>& lhs, const typename std::iterator_traits<BiIter>::value_type& rhs ); | (42) | (since C++11)

Compares a `sub_match` to another `sub_match`, a string, a null-terminated character sequence or a character.

1-6) Compares two sub_match directly by comparing their underlying character sequences. Implemented using lhs.str().compare(rhs.str())
7-18) Compares a sub_match with a std::basic_string. Implemented using sm.str().compare(st), where `sm` is a `sub_match` and `st` is a `basic_string`.
19-30) Compares a sub_match with a null-terminated string. Implemented using sm.str().compare(s), where `sm` is a `sub_match` and `s` is a pointer to a null-terminated character string.
31-42) Compares a sub_match with a character. Implemented using the following:

sm.str().compare(typename sub_match<BidirIt>::string_type(1, ch)), where `sm` is a `sub_match` and `ch` is a character.

### [edit] Parameters

lhs, rhs | - | a `sub_match`, `basic_string`, pointer to a null-terminated string or a character to compare

### [edit] Return value

true if the corresponding comparison holds as defined by compare(), false otherwise.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

compare | compares matched subsequence (if any) (public member function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/regex/sub_match/operator_cmp&oldid=61476"
Category:

- Todo no example