各对象相等比较。
template<class BidIt>
bool operator==(const sub_match<BidIt>& left,
const sub_match<BidIt>& right);
template<class BidIt, class IOtraits, class Alloc>
bool operator==(
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& left,
const sub_match<BidIt>& right);
template<class BidIt, class IOtraits, class Alloc>
bool operator==(const sub_match<BidIt>& left,
const basic_string<typename iterator_traits<BidIt>::value_type, IOtraits, Alloc>& right);
template<class BidIt>
bool operator==(const typename iterator_traits<BidIt>::value_type* left,
const sub_match<BidIt>& right);
template<class BidIt>
bool operator==(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type* right);
template<class BidIt>
bool operator==(const typename iterator_traits<BidIt>::value_type& left,
const sub_match<BidIt>& right);
template<class BidIt>
bool operator==(const sub_match<BidIt>& left,
const typename iterator_traits<BidIt>::value_type& right);
template<class BidIt, class Alloc>
bool operator==(const match_results<BidIt, Alloc>& left,
const match_results<BidIt, Alloc>& right);
参数
BidIt
迭代器类型。IOtraits
字符串字符类。Alloc
分配程序类。left
比较的对象。right
比较的对象。
备注
每个模板运算符转换参数中的每一个都为字符串类型的相等性比较并返回转换对象的结果。
当模板转换运算符参数为字符串类型时它使用应用的第一天转换:
类型是类模板专用化 match_results 或 sub_match 的参数通过调用 str 成员函数转换;
类型是类模板的专用化;未更改的 basic_string 参数。
其他参数类型通过将参数值强制转换为相应的 basic_string类模板的专用化的构造函数。
示例
// std_tr1__regex__operator_eq.cpp
// compile with: /EHsc
#include <regex>
#include <iostream>
typedef std::cmatch::string_type Mystr;
int main()
{
std::regex rx("c(a*)|(b)");
std::cmatch mr;
std::regex_search("xcaaay", mr, rx);
std::csub_match sub = mr[1];
std::cout << "match == " << mr.str() << std::endl;
std::cout << "sub == " << sub << std::endl;
std::cout << std::endl;
std::cout << "match == match == " << std::boolalpha
<< (mr == mr) << std::endl;
std::cout << "sub == sub == " << std::boolalpha
<< (sub == sub) << std::endl;
std::cout << "string(\"aab\") == sub == " << std::boolalpha
<< (Mystr("aab") == sub) << std::endl;
std::cout << "sub == string(\"aab\") == " << std::boolalpha
<< (sub == Mystr("aab")) << std::endl;
std::cout << "\"aab\" == sub == " << std::boolalpha
<< ("aab" == sub) << std::endl;
std::cout << "sub == \"aab\" == " << std::boolalpha
<< (sub == "aab") << std::endl;
std::cout << "'a' == sub == " << std::boolalpha
<< ('a' == sub) << std::endl;
std::cout << "sub == 'a' == " << std::boolalpha
<< (sub == 'a') << std::endl;
return (0);
}
要求
标头: <regex>
命名空间: std