[basic.ios.members]

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

## 31.5 Iostreams base classes [[iostreams.base]](iostreams.base#basic.ios.members)

### 31.5.4 Class template basic_ios [[ios]](ios#basic.ios.members)

#### 31.5.4.3 Member functions [basic.ios.members]

[ð](#lib:tie,basic_ios)

`basic_ostream<charT, traits>* tie() const;
`

[1](#1)

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

*Returns*: An output sequence that is*tied* to (synchronized with) the sequence controlled by the stream buffer[.](#1.sentence-1)

[ð](#lib:tie,basic_ios_)

`basic_ostream<charT, traits>* tie(basic_ostream<charT, traits>* tiestr);
`

[2](#2)

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

*Preconditions*: If tiestr is not null, tiestr is not reachable by
traversing the linked list of tied stream objects starting fromtiestr->tie()[.](#2.sentence-1)

[3](#3)

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

*Postconditions*: tiestr == tie()[.](#3.sentence-1)

[4](#4)

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

*Returns*: The previous value oftie()[.](#4.sentence-1)

[ð](#lib:rdbuf,basic_ios)

`basic_streambuf<charT, traits>* rdbuf() const;
`

[5](#5)

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

*Returns*: A pointer to thestreambuf associated with the stream[.](#5.sentence-1)

[ð](#lib:rdbuf,basic_ios_)

`basic_streambuf<charT, traits>* rdbuf(basic_streambuf<charT, traits>* sb);
`

[6](#6)

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

*Effects*: Callsclear()[.](#6.sentence-1)

[7](#7)

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

*Postconditions*: sb == rdbuf()[.](#7.sentence-1)

[8](#8)

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

*Returns*: The previous value ofrdbuf()[.](#8.sentence-1)

[ð](#lib:imbue,basic_ios)

`locale imbue(const locale& loc);
`

[9](#9)

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

*Effects*: Calls[ios_base​::​imbue](ios.base.locales#lib:ios_base,imbue "31.5.2.4 Functions [ios.base.locales]")(loc) and
ifrdbuf() != 0 thenrdbuf()->[pubimbue](streambuf.locales#lib:basic_streambuf,pubimbue "31.6.3.3.1 Locales [streambuf.locales]")(loc)[.](#9.sentence-1)

[10](#10)

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

*Returns*: The prior value ofios_base​::​imbue()[.](#10.sentence-1)

[ð](#lib:narrow,basic_ios)

`char narrow(char_type c, char dfault) const;
`

[11](#11)

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

*Returns*: use_facet<ctype<char_type>>(getloc()).narrow(c, dfault)[.](#11.sentence-1)

[ð](#lib:widen,basic_ios)

`char_type widen(char c) const;
`

[12](#12)

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

*Returns*: use_facet<ctype<char_type>>(getloc()).widen(c)[.](#12.sentence-1)

[ð](#lib:fill,basic_ios)

`char_type fill() const;
`

[13](#13)

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

*Returns*: The character used to pad (fill) an output conversion to the specified
field width[.](#13.sentence-1)

[ð](#lib:fill,basic_ios_)

`char_type fill(char_type fillch);
`

[14](#14)

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

*Postconditions*: traits​::​eq(fillch, fill())[.](#14.sentence-1)

[15](#15)

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

*Returns*: The previous value offill()[.](#15.sentence-1)

[ð](#lib:copyfmt,basic_ios)

`basic_ios& copyfmt(const basic_ios& rhs);
`

[16](#16)

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

*Effects*: If(this == addressof(rhs)) is true does nothing[.](#16.sentence-1)

Otherwise assigns to the member objects of*this the corresponding member objects of rhs as follows:

- [(16.1)](#16.1)

calls each registered callback pair (fn, idx) as(*fn)(erase_event, *this, idx);

- [(16.2)](#16.2)

then, assigns to the member objects of *this the corresponding member objects ofrhs, except that
  * [(16.2.1)](#16.2.1)

rdstate(), rdbuf(), and exceptions() are left unchanged;

  * [(16.2.2)](#16.2.2)

the contents of arrays pointed at by pword and iword are copied,
not the pointers themselves;[263](#footnote-263 "This suggests an infinite amount of copying, but the implementation can keep track of the maximum element of the arrays that is nonzero.") and

  * [(16.2.3)](#16.2.3)

if any newly stored pointer values in *this point at objects stored outside
the object rhs and those objects are destroyed when rhs is destroyed, the
newly stored pointer values are altered to point at newly constructed copies of the
objects;

- [(16.3)](#16.3)

then, calls each callback pair that was copied from rhs as(*fn)(copyfmt_event, *this, idx);

- [(16.4)](#16.4)

then, calls exceptions(rhs.exceptions())[.](#16.sentence-2)

[17](#17)

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

[*Note [1](#note-1)*:

The second pass through the callback pairs permits a copied pword value to be zeroed, or to have its referent deep copied or reference counted, or to have
other special action taken[.](#17.sentence-1)

â *end note*]

[18](#18)

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

*Postconditions*: The postconditions of this function are indicated in Table [143](#tab:basic.ios.copyfmt "Table 143: basic_­ios​::​copyfmt() effects")[.](#18.sentence-1)

Table [143](#tab:basic.ios.copyfmt) — basic_ios​::​copyfmt() effects [[tab:basic.ios.copyfmt]](./tab:basic.ios.copyfmt)  

| [ð](#tab:basic.ios.copyfmt-row-1)<br>**Element** | **Value** |
| --- | --- |
| [ð](#tab:basic.ios.copyfmt-row-2)<br>rdbuf() | *unchanged* |
| [ð](#tab:basic.ios.copyfmt-row-3)<br>tie() | rhs.tie() |
| [ð](#tab:basic.ios.copyfmt-row-4)<br>rdstate() | *unchanged* |
| [ð](#tab:basic.ios.copyfmt-row-5)<br>exceptions() | rhs.exceptions() |
| [ð](#tab:basic.ios.copyfmt-row-6)<br>flags() | rhs.flags() |
| [ð](#tab:basic.ios.copyfmt-row-7)<br>width() | rhs.width() |
| [ð](#tab:basic.ios.copyfmt-row-8)<br>precision() | rhs.precision() |
| [ð](#tab:basic.ios.copyfmt-row-9)<br>fill() | rhs.fill() |
| [ð](#tab:basic.ios.copyfmt-row-10)<br>getloc() | rhs.getloc() |

[19](#19)

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

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

[ð](#lib:move,basic_ios)

`void move(basic_ios& rhs);
void move(basic_ios&& rhs);
`

[20](#20)

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

*Postconditions*: *this has the state thatrhs had before the function call, except thatrdbuf() returns nullptr[.](#20.sentence-1)

rhs is in a valid but
unspecified state, except that rhs.rdbuf() returns the
same value as it returned before the function call, andrhs.tie() returns nullptr[.](#20.sentence-2)

[ð](#lib:swap,basic_ios)

`void swap(basic_ios& rhs) noexcept;
`

[21](#21)

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

*Effects*: The states of *this and rhs are exchanged, except that rdbuf() returns the same
value as it returned before the function call, and rhs.rdbuf() returns the same value as it returned before the function call[.](#21.sentence-1)

[ð](#lib:set_rdbuf,basic_ios)

`void set_rdbuf(basic_streambuf<charT, traits>* sb);
`

[22](#22)

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

*Preconditions*: sb != nullptr is true[.](#22.sentence-1)

[23](#23)

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

*Effects*: Associates the basic_streambuf object
pointed to by sb with this stream without callingclear()[.](#23.sentence-1)

[24](#24)

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

*Postconditions*: rdbuf() == sb is true[.](#24.sentence-1)

[25](#25)

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

*Throws*: Nothing[.](#25.sentence-1)

[263)](#footnote-263)[263)](#footnoteref-263)

This suggests an infinite amount of copying, but the implementation can keep
track of the maximum element of the arrays that is nonzero[.](#footnote-263.sentence-1)
