std::swap
std::swap (std::basic_syncbuf 특수화)
std::swap 알고리즘을 std::basic_syncbuf에 대해 오버로드한 함수예요. 두 동기화 버퍼의 상태를 서로 바꿔요. C++20부터 있어요.
출처: cppreference
본문
<syncstream> 헤더에 정의돼 있고, std::basic_syncbuf용 swap 오버로드예요.
template< class CharT, class Traits, class Allocator >
void swap( std::basic_syncbuf<CharT, Traits, Allocator>& lhs,
std::basic_syncbuf<CharT, Traits, Allocator>& rhs );
lhs의 상태를 rhs의 상태와 교환해요. 내부적으로 lhs.swap(rhs)를 호출해요.
- 매개변수
lhs,rhs: 상태를 바꿀std::basic_syncbuf객체들. - 반환 값: 없음.
std::basic_syncbuf는 스레드 간 동기화된 출력을 위한 스트림 버퍼예요. 이 swap 오버로드 덕분에 일반화된 코드에서도 두 버퍼의 상태를 쉽게 교환할 수 있어요. 예제 섹션은 아직 미완성으로 표시돼 있어요.