Namespaces
Variants

std::sub_match<BidirIt>:: compare

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
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_match std::basic_string 进行比较。等价于 str ( ) . compare ( s )
3) sub_match 与由 s 指向的底层字符类型的空终止序列进行比较。等价于 str ( ) . compare ( c )

目录

参数

m - 指向另一个子匹配项的引用
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 、字符串或字符
(函数模板)