std::sub_match<BidirIt>:: swap
|
void
swap
(
sub_match
&
s
)
noexcept
(
/* see below */
)
;
|
(C++11 이후) | |
두 개의 부분 일치 객체의 내용을 교환합니다. 다음과 동일합니다:
this
-
>
pair
<
BidirIt, BidirIt
>
::
swap
(
s
)
;
std::
swap
(
matched, s.
matched
)
;
목차 |
매개변수
| s | - |
교환할
sub_match
|
| 타입 요구사항 | ||
-
BidirIt
는
LegacySwappable
요구사항을 충족해야 합니다.
|
||
예외
예제
#include <cassert> #include <iostream> #include <regex> int main() { const char* s = "Quick red cat"; std::sub_match<const char*> x, y; x.first = &s[0]; x.second = &s[5]; x.matched = false; y.first = &s[012]; y.second = &s[13]; y.matched = true; std::cout << "Before swap:\n"; std::cout << "x.str() = [" << x.str() << "]\n"; std::cout << "y.str() = [" << y.str() << "]\n"; assert(!x.matched and y.matched); x.swap(y); std::cout << "After swap:\n"; std::cout << "x.str() = [" << x.str() << "]\n"; std::cout << "y.str() = [" << y.str() << "]\n"; assert(x.matched and !y.matched); }
출력:
Before swap: x.str() = [] y.str() = [cat] After swap: x.str() = [cat] y.str() = []
결함 보고서
다음 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 3204 | C++11 |
std::sub_match
가 상속받은
std
::
pair
::
swap
(
pair
&
)
를 사용하여 슬라이싱 문제 발생 |
std :: sub_match :: swap ( sub_match & ) 가 추가됨 |