名稱空間
變體
操作

operator==,!=,<,<=,>,>=,<=>(std::sub_match)

來自 cppreference.com
< cpp‎ | regex‎ | sub_match
 
 
 
正則表示式庫
(C++11)
演算法
迭代器
異常
特性
常量
(C++11)
正則表示式語法
 
std::sub_match
成員函式
非成員函式
operator==operator!=operator<operator<=operator>operator>=operator<=>
(直至 C++20)(直至 C++20)(直至 C++20)(直至 C++20)(直至 C++20)(C++20 起)
 
在標頭檔案 <regex> 中定義
直接比較
template< class BidirIt >

bool operator== ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(1) (C++11 起)
template< class BidirIt >

bool operator!= ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(2) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<  ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(3) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<= ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(4) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>  ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(5) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>= ( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(6) (C++11 起)
(C++20 前)
template< class BidirIt >

auto operator<=>( const std::sub_match<BidirIt>& lhs,

                  const std::sub_match<BidirIt>& rhs );
(7) (C++20 起)
template< class BidirIt, class Traits, class Alloc >

bool operator== ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(8) (C++11 起)
template< class BidirIt, class Traits, class Alloc >

bool operator!= ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(9) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator<  ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(10) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator<= ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(11) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator>  ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(12) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator>= ( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(13) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

auto operator<=>( const std::sub_match<BidirIt>& lhs,
                  const std::basic_string</*value-type-of*/<BidirIt>,

                                          Traits, Alloc>& str );
(14) (C++20 起)
template< class BidirIt, class Traits, class Alloc >

bool operator== ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(15) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator!= ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(16) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator<  ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(17) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator<= ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(18) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator>  ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(19) (C++11 起)
(C++20 前)
template< class BidirIt, class Traits, class Alloc >

bool operator>= ( const std::basic_string</*value-type-of*/<BidirIt>,
                                          Traits, Alloc>& str,

                  const std::sub_match<BidirIt>& rhs );
(20) (C++11 起)
(C++20 前)
與 C 風格字串比較
template< class BidirIt >

bool operator== ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(21) (C++11 起)
template< class BidirIt >

bool operator!= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(22) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<  ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(23) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(24) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>  ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(25) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(26) (C++11 起)
(C++20 前)
template< class BidirIt >

auto operator<=>( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>* s );
(27) (C++20 起)
template< class BidirIt >

bool operator== ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(28) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator!= ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(29) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<  ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(30) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<= ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(31) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>  ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(32) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>= ( const /*value-type-of*/<BidirIt>* s,

                  const std::sub_match<BidirIt>& rhs );
(33) (C++11 起)
(C++20 前)
與單個字元比較
template< class BidirIt >

bool operator== ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(34) (C++11 起)
template< class BidirIt >

bool operator!= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(35) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<  ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(36) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(37) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>  ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(38) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>= ( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(39) (C++11 起)
(C++20 前)
template< class BidirIt >

auto operator<=>( const std::sub_match<BidirIt>& lhs,

                  const /*value-type-of*/<BidirIt>& ch );
(40) (C++20 起)
template< class BidirIt >

bool operator== ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(41) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator!= ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(42) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<  ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(43) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator<= ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(44) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>  ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(45) (C++11 起)
(C++20 前)
template< class BidirIt >

bool operator>= ( const /*value-type-of*/<BidirIt>& ch,

                  const std::sub_match<BidirIt>& rhs );
(46) (C++11 起)
(C++20 前)
輔助類型別名
template< class BidirIt >

using /*value-type-of*/ =

    typename std::iterator_traits<BidirIt>::value_type;
(47) (僅作說明*)
template< class BidirIt >

using /*cat-type-of*/ =
    std::compare_three_way_result_t

        <std::basic_string</*value-type-of*/<BidirIt>>>;
(48) (C++20 起)
(僅作說明*)

比較 sub_match 與另一個 sub_matchstd::string、C 風格字串或單個字元。

1-7) 直接比較兩個 sub_match
8-20) 比較 sub_matchstd::basic_string
21-33) 比較 sub_match 與 C 風格字串。
34-46) 比較 sub_match 與單個字元。

<<=>>=!= 運算子分別從 operator<=>operator== 合成

(C++20 起)
47) value-type-of <BidirIt>BidirIt值型別
48) cat-type-of <BidirIt>std::sub_match<BidirIt> 的三向比較結果型別。

目錄

[編輯] 引數

lhs, rhs - 要比較的 sub_match
str - 要比較的 std::basic_string
s - 指向要比較的 C 風格字串的指標
ch - 要比較的字元

[編輯] 返回值

target 為下列值

1-7) rhs
8-20) typename std::sub_match<BidirIt>::string_type(str.data(), str.size())
21-33) s
34-46) typename std::sub_match<BidirIt>::string_type(1, ch)

返回值定義如下:

 運算子  返回值
過載 (1-14,21-27,34-40)
(帶引數 lhs 的過載)
      過載 (15-20,28-33,41-46)      
(不帶引數 lhs 的過載)
== lhs.compare(target) == 0 rhs.compare(target) == 0
!= lhs.compare(target) != 0 rhs.compare(target) != 0
< lhs.compare(target) < 0 rhs.compare(target) > 0
<= lhs.compare(target) <= 0 rhs.compare(target) >= 0
> lhs.compare(target) > 0 rhs.compare(target) < 0
>= lhs.compare(target) >= 0 rhs.compare(target) <= 0
<=>  static_cast<cat-type-of <BidirIt>>
    (lhs.compare(target) <=> 0)
 
不適用

[編輯] 注意

operator<=> 的返回型別保證為比較類別型別。若 value-type-of <BidirIt>charwchar_tchar8_tchar16_tchar32_t,則 operator<=> 的返回型別是 std::strong_ordering

[編輯] 示例

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 2217 C++11 對於與 std::string 的比較,compare()
引數為 str.c_str()
引數為
string_type(str.data(), str.size()))

[編輯] 參閱

比較匹配的子序列(若有)
(public member function) [編輯]