std::swap

std::swap (std::basic_stringstream 특수화)

std::swap 알고리즘을 std::basic_stringstream에 대해 오버로드한 함수예요. 두 문자열 스트림의 상태를 서로 바꿔요. C++11부터 있어요.

출처: cppreference

본문

<sstream> 헤더에 정의돼 있고, std::basic_stringstreamswap 오버로드예요.

template< class CharT, class Traits, class Alloc >
void swap( std::basic_stringstream<CharT,Traits,Alloc>& lhs,
           std::basic_stringstream<CharT,Traits,Alloc>& rhs );

lhs의 상태를 rhs의 상태와 교환해요. 내부적으로 lhs.swap(rhs)를 호출해요.

  • 매개변수 lhs, rhs: 상태를 바꿀 스트림들이에요.
  • 반환 값: 없음.
  • 예외: 구현 정의 방식의 예외를 던질 수 있어요.

std::basic_stringstream은 문자열을 입출력 스트림처럼 다루는 클래스예요. 이 swap 오버로드 덕분에 일반화된 코드에서도 두 스트림의 상태를 쉽게 교환할 수 있어요. 예제 섹션은 아직 미완성으로 표시돼 있어요.

더 알아보기 (Learn more)

cppreference