std::match_results<BidirIt,Alloc>::ready
來自 cppreference.com
< cpp | regex | match results
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.