[stringbuf.assign]

# 31 Input/output library [[input.output]](./#input.output)

## 31.8 String-based streams [[string.streams]](string.streams#stringbuf.assign)

### 31.8.2 Class template basic_stringbuf [[stringbuf]](stringbuf#assign)

#### 31.8.2.3 Assignment and swap [stringbuf.assign]

[ð](#lib:operator=,basic_stringbuf)

`basic_stringbuf& operator=(basic_stringbuf&& rhs);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8343)

*Effects*: After the move assignment *this has the observable state it would
have had if it had been move constructed from rhs (see [[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8348)

*Returns*: *this[.](#2.sentence-1)

[ð](#lib:swap,basic_stringbuf)

`void swap(basic_stringbuf& rhs) noexcept(see below);
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8359)

*Preconditions*: allocator_traits<Allocator>​::​propagate_on_container_swap​::​value is true orget_allocator() == rhs.get_allocator() is true[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8365)

*Effects*: Exchanges the state of *this and rhs[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8370)

*Remarks*: The exception specification is equivalent to:  

allocator_traits<Allocator>​::​propagate_on_container_swap​::​value ||  

allocator_traits<Allocator>​::​is_always_equal​::​value

[ð](#lib:swap,basic_stringbuf_)

`template<class charT, class traits, class Allocator>
  void swap(basic_stringbuf<charT, traits, Allocator>& x,
            basic_stringbuf<charT, traits, Allocator>& y) noexcept(noexcept(x.swap(y)));
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8385)

*Effects*: Equivalent to x.swap(y)[.](#6.sentence-1)
