-
[c++] regex swap 함수Programming/c++ 2023. 1. 20. 14:07728x90
1.함수 헤더 파일
#include <regex>
2.함수 원형
template <class Elem, class RXtraits> void swap( basic_regex<Elem, RXtraits, Alloc>& left, basic_regex<Elem, RXtraits>& right) noexcept; template <class Elem, class IOtraits, class BidIt, class Alloc> void swap( match_results<BidIt, Alloc>& left, match_results<BidIt, Alloc>& right) noexcept;
3. Parameter
Elem The type of element to find a match for. RXtraits The attribute class for the element. 4. Described
템플릿 함수는 일정한 시간 내에 인수의 내용을 교환하고 예외를 발생시키지 않습니다.
4.예제
#include <regex> #include <iostream> int main() { regex rx0("c(a*)|(b)"); regex rx1; cmatch mr0; cmatch mr1; swap(rx0, rx1); regex_search("xcaaay", mr1, rx1); swap(mr0, mr1); csub_match sub = mr0[1]; cout << "matched == " << boolalpha << sub.matched << endl; cout << "length == " << sub.length() << endl; cout << "string == " << sub << endl; }
728x90'Programming > c++' 카테고리의 다른 글
[c++] 2진수 1의 개수 세기 (0) 2023.02.05 [c++] basic_regex class (0) 2023.01.20 [c++] regex_replace 함수 (0) 2023.01.20 [c++] regex_match 함수 (0) 2023.01.20 [c++] regex 라이브러리 (0) 2023.01.20