std::match_results<BidirIt,Alloc>:: ready
From cppreference.net
<
cpp
|
regex
|
match results
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Regular expressions library
| Classes | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Algorithms | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Iterators | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Exceptions | ||||
|
(C++11)
|
||||
| Traits | ||||
|
(C++11)
|
||||
| Constants | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Regex Grammar | ||||
|
(C++11)
|
std::match_results
| Member functions | ||||
| State | ||||
|
match_results::ready
|
||||
| Element access | ||||
| Iterators | ||||
| Format | ||||
| Modifiers | ||||
| Non-member functions | ||||
|
(until C++20)
|
||||
|
bool
ready
(
)
const
;
|
(自 C++11 起) | |
指示匹配结果是否已就绪(有效)。
默认构造的匹配结果不具备结果状态(不处于 就绪 状态),只能通过正则表达式算法使其就绪。 就绪 状态意味着所有匹配结果已完全建立。
调用未就绪的
match_results
对象的大多数成员函数的结果是未定义的。
返回值
true 表示匹配结果已就绪, false 表示未就绪。
示例
运行此代码
#include <iostream> #include <regex> #include <string> int main() { std::string target("big-red-cat"); std::smatch sm; std::cout << "Default constructed smatch is " << (sm.ready() ? "ready.\n" : "not ready.\n"); std::regex re1(".*-red-.*"); std::regex_search(target, sm, re1); std::cout << "After search, smatch is " << (sm.ready() ? "ready.\n" : "not ready.\n"); }
输出:
Default constructed smatch is not ready. After search, smatch is ready.