function template
<regex>
std::operators (sub_match)
(1) |
template <class I> bool operator==(const sub_match<I>& lhs, const sub_match<I>& rhs);
|
---|
(2) |
template <class I, class T, class A> bool operator==
(const basic_string<typename iterator_traits<I>::value_type,T,A>& lhs, const sub_match& rhs);
|
---|
(3) |
template <class I, class T, class A> bool operator==
(const sub_match& lhs, const basic_string<typename iterator_traits<I>::value_type,T,A>& rhs);
|
---|
(4) |
template <class I> bool operator==
(const typename iterator_traits<I>::value_type* lhs, const sub_match<i>& rhs);
|
---|
(5) |
template <class I> bool operator==
(const sub_match<i>& lhs, const typename iterator_traits<I>::value_type* rhs);
|
---|
(6) |
template <class I> bool operator==
(const typename iterator_traits<I>::value_type& lhs, const sub_match<I>& rhs);
|
---|
(7) |
template <class I> bool operator==
(const sub_match<I>& lhs, const typename iterator_traits<I>::value_type& rhs);
|
---|
also |
/* also defined for the following operators:
operator!=
operator<
operator>
operator>=
operator<=
with the same 7 signatures as for operator== */ |
---|
Relational operators for sub_match
Returns the result of the appropriate relational operation between lhs and rhs as if both where string objects.
The function uses sub_match::compare.
Parameters
- lhs, rhs
- sub_match or string-like objects (to the left- and right-hand side of the operator, respectively), operating both on the same type of characters.
Return Value
true if the condition holds, and false otherwise.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// sub_match relational operators
#include <iostream>
#include <regex>
int main ()
{
using namespace std::regex_constants;
std::cmatch m;
std::regex_search ( "there is a needle in this haystack", m, std::regex("n\\w+") );
if (m[0]=="needle") std::cout << "needle found!" << std::endl;
return 0;
}
|
Output: