Namespaces
Variants

std::match_results<BidirIt,Alloc>:: ready

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
bool ready ( ) const ;
(C++11 이후)

매치 결과가 준비되었는지(유효한지) 여부를 나타냅니다.

기본 생성된 매치 결과는 결과 상태가 없으며(준비 상태가 아님), 정규식 알고리즘 중 하나에 의해서만 준비 상태로 만들 수 있습니다. ready 상태는 모든 매치 결과가 완전히 확립되었음을 의미합니다.

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.