std::sub_match<BidirIt>::compare

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

目录

[编辑] 参数

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

[编辑] 返回值

若此 sub_match 小于 另一字符序列则为小于零的值,若两个底层字符序列相等则为零,若此 sub_match 大于 另一字符序列则为大于零的值。

[编辑] 注解

应用代码很少直接使用此函数。它们替而使用非成员比较运算符之一。

[编辑] 示例

[编辑] 参阅

比较两个字符串
(std::basic_string<CharT,Traits,Allocator> 的公开成员函数) [编辑]
转换为底层字符串类型
(公开成员函数) [编辑]
(C++20 移除)(C++20 移除)(C++20 移除)(C++20 移除)(C++20 移除)(C++20)
比较一个 sub_match 与另一 sub_match 、字符串或字符
(函数模板) [编辑]