operator==,!=,<,<=,>,>=,<=>(std::sub_match)
Определён в заголовочном файле <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) |
Сравнение с std::basic_string
| ||
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_match, std::string, строкой в стиле C или отдельным символом.
sub_match.sub_match со строкой в стиле C.sub_match с отдельным символом.| Операторы | (начиная с C++20) |
cat-type-of <BidirIt> — это тип результата трёхстороннего сравнения std::sub_match<BidirIt>.Параметры
| lhs, rhs | - | объект sub_match для сравнения |
| str | - | объект std::basic_string для сравнения |
| s | - | указатель на строку в стиле C для сравнения |
| ch | - | символ для сравнения |
Возвращаемое значение
Пусть target обозначает следующие значения:
rhs
typename std::sub_match<BidirIt>::string_type(str.data(), str.size())
s
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> — это char, wchar_t, char8_t, char16_t или char32_t, тип результата operator<=> — это std::strong_ordering.
Пример
Отчёты об ошибках
Следующие отчёты об ошибках, изменяющие поведение, были применены ретроактивно к ранее опубликованным стандартам C++.
| DR | Применяется к | Поведение согласно опубликованной версии | Корректное поведение |
|---|---|---|---|
| LWG 2217 | C++11 | для сравнений с std::stringаргументом compare() было str.c_str() | аргументом являетсяstring_type(str.data(), str.size())) |
См. также
| сравнивает совпавшую подпоследовательность (если она есть) (открытая функция-член) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/regex/sub_match/operator_cmp