std::basic_istream<CharT,Traits>:: operator=
From cppreference.net
<
cpp
|
io
|
basic istream
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::basic_istream
| Global objects | ||||
| Member functions | ||||
|
basic_istream::operator=
(C++11)
|
||||
| Formatted input | ||||
| Unformatted input | ||||
| Positioning | ||||
| Miscellaneous | ||||
|
(C++11)
|
||||
| Member classes | ||||
| Non-member functions | ||||
|
protected
:
basic_istream & operator = ( const basic_istream & rhs ) = delete ; |
(1) | |
|
protected
:
basic_istream & operator = ( basic_istream && rhs ) ; |
(2) | (C++11부터) |
1)
복사 할당 연산자는 protected로 선언되었으며 삭제되었습니다. 입력 스트림은 CopyAssignable이 아닙니다.
2)
이동 대입 연산자는
gcount()
값과 기본 클래스의 모든 데이터 멤버를
rdbuf()
를 제외하고
rhs
와 교환합니다. 마치
swap
(
*
rhs
)
를 호출하는 것처럼 동작합니다. 이 이동 대입 연산자는 protected로 선언되어 있습니다: 파생된 이동 가능 입력 스트림 클래스인
std::basic_ifstream
와
std::basic_istringstream
의 이동 대입 연산자에 의해서만 호출되며, 이들은 관련된 스트림 버퍼를 올바르게 이동 대입하는 방법을 알고 있습니다.
매개변수
| rhs | - | * this 에 할당할 basic_istream 객체 |
예제
이 코드 실행
#include <iostream> #include <sstream> int main() { std::istringstream s1; s1 = std::istringstream("test"); // OK // std::cin = std::istringstream("test"); // ERROR: 'operator=' is protected }