命名空间
变体
操作

std::sub_match<BidirIt>::compare

来自 cppreference.cn
< cpp‎ | regex‎ | sub match
 
 
 
正则表达式库
(C++11)
算法
迭代器
异常
特性
常量
(C++11)
正则表达式语法
 
 
int compare( const sub_match& m ) const;
(1) (since C++11)
int compare( const string_type& s ) const;
(2) (since C++11)
int compare( const value_type* c ) const;
(3) (since C++11)
1) 直接比较两个 sub_match,通过比较它们底层的字符序列。等价于 str().compare(m.str())
2)sub_matchstd::basic_string 进行比较。等价于 str().compare(s)
3)sub_match 与由 s 指向的底层字符类型的空终止序列进行比较。等价于 str().compare(c)

内容

[edit] 参数

m - 另一个 sub_match 的引用
s - 要比较的字符串的引用
c - 指向要比较的底层 value_type 的空终止字符序列的指针

[edit] 返回值

如果此 sub_match 小于另一个字符序列,则返回小于零的值;如果两个底层字符序列相等,则返回零;如果此 sub_match 大于另一个字符序列,则返回大于零的值。

[edit] 注释

此函数很少被应用程序代码直接使用。通常使用非成员比较运算符之一。

[edit] 示例

[edit] 参见

比较两个字符串
(public member function of std::basic_string<CharT,Traits,Allocator>) [编辑]
转换为底层字符串类型
(public member function) [编辑]
(removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(removed in C++20)(C++20)
sub_match 与另一个 sub_match、字符串或字符进行比较
(function template) [编辑]