Files
2025-10-25 03:02:53 +03:00

3146 lines
139 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[iostream.format]
# 31 Input/output library [[input.output]](./#input.output)
## 31.7 Formatting and manipulators [iostream.format]
### [31.7.1](#istream.syn) Header <istream> synopsis [[istream.syn]](istream.syn)
[🔗](#header:%3cistream%3e)
namespace std {// [[istream]](#istream "31.7.5.2Class template basic_­istream"), class template basic_istreamtemplate<class charT, class traits = char_traits<charT>>class basic_istream; using istream = basic_istream<char>; using wistream = basic_istream<wchar_t>; // [[iostreamclass]](#iostreamclass "31.7.5.7Class template basic_­iostream"), class template basic_iostreamtemplate<class charT, class traits = char_traits<charT>>class basic_iostream; using iostream = basic_iostream<char>; using wiostream = basic_iostream<wchar_t>; // [[istream.manip]](#istream.manip "31.7.5.5Standard basic_­istream manipulators"), standard basic_istream manipulatorstemplate<class charT, class traits> basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is); // [[istream.rvalue]](#istream.rvalue "31.7.5.6Rvalue stream extraction"), rvalue stream extractiontemplate<class Istream, class T> Istream&& operator>>(Istream&& is, T&& x);}
### [31.7.2](#ostream.syn) Header <ostream> synopsis [[ostream.syn]](ostream.syn)
[🔗](#header:%3costream%3e)
namespace std {// [[ostream]](#ostream "31.7.6.2Class template basic_­ostream"), class template basic_ostreamtemplate<class charT, class traits = char_traits<charT>>class basic_ostream; using ostream = basic_ostream<char>; using wostream = basic_ostream<wchar_t>; // [[ostream.manip]](#ostream.manip "31.7.6.5Standard basic_­ostream manipulators"), standard basic_ostream manipulatorstemplate<class charT, class traits> basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& ends(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os); template<class charT, class traits> basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os); // [[ostream.rvalue]](#ostream.rvalue "31.7.6.6Rvalue stream insertion"), rvalue stream insertiontemplate<class Ostream, class T> Ostream&& operator<<(Ostream&& os, const T& x); // [[ostream.formatted.print]](#ostream.formatted.print "31.7.6.3.5Print"), print functionstemplate<class... Args>void print(ostream& os, format_string<Args...> fmt, Args&&... args); template<class... Args>void println(ostream& os, format_string<Args...> fmt, Args&&... args); void println(ostream& os); void vprint_unicode(ostream& os, string_view fmt, format_args args); void vprint_nonunicode(ostream& os, string_view fmt, format_args args);}
### [31.7.3](#iomanip.syn) Header <iomanip> synopsis [[iomanip.syn]](iomanip.syn)
[🔗](#header:%3ciomanip%3e)
namespace std {// [[std.manip]](#std.manip "31.7.7Standard manipulators"), standard manipulators*unspecified* resetiosflags(ios_base::fmtflags mask); *unspecified* setiosflags (ios_base::fmtflags mask); *unspecified* setbase(int base); template<class charT> *unspecified* setfill(charT c); *unspecified* setprecision(int n); *unspecified* setw(int n); // [[ext.manip]](#ext.manip "31.7.8Extended manipulators"), extended manipulatorstemplate<class moneyT> *unspecified* get_money(moneyT& mon, bool intl = false); template<class moneyT> *unspecified* put_money(const moneyT& mon, bool intl = false); template<class charT> *unspecified* get_time(tm* tmb, const charT* fmt); template<class charT> *unspecified* put_time(const tm* tmb, const charT* fmt); // [[quoted.manip]](#quoted.manip "31.7.9Quoted manipulators"), quoted manipulatorstemplate<class charT>*unspecified* quoted(const charT* s, charT delim = charT('"'), charT escape = charT('\\')); template<class charT, class traits, class Allocator>*unspecified* quoted(const basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\')); template<class charT, class traits, class Allocator>*unspecified* quoted(basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\')); template<class charT, class traits>*unspecified* quoted(basic_string_view<charT, traits> s,
charT delim = charT('"'), charT escape = charT('\\'));}
### [31.7.4](#print.syn) Header <print> synopsis [[print.syn]](print.syn)
[🔗](#header:%3cprint%3e)
namespace std {// [[print.fun]](#print.fun "31.7.10Print functions"), print functionstemplate<class... Args>void print(format_string<Args...> fmt, Args&&... args); template<class... Args>void print(FILE* stream, format_string<Args...> fmt, Args&&... args); template<class... Args>void println(format_string<Args...> fmt, Args&&... args); void println(); template<class... Args>void println(FILE* stream, format_string<Args...> fmt, Args&&... args); void println(FILE* stream); void vprint_unicode(string_view fmt, format_args args); void vprint_unicode(FILE* stream, string_view fmt, format_args args); void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args args); void vprint_nonunicode(string_view fmt, format_args args); void vprint_nonunicode(FILE* stream, string_view fmt, format_args args); void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args args);}
### [31.7.5](#input.streams) Input streams [[input.streams]](input.streams)
#### [31.7.5.1](#input.streams.general) General [[input.streams.general]](input.streams.general)
[1](#input.streams.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4287)
The header [<istream>](#header:%3cistream%3e "31.7.1Header <istream> synopsis[istream.syn]") defines two class templates
and a function template that control input from a stream buffer,
along with a function template that extracts from stream rvalues[.](#input.streams.general-1.sentence-1)
#### [31.7.5.2](#istream) Class template basic_istream [[istream]](istream)
#### [31.7.5.2.1](#istream.general) General [[istream.general]](istream.general)
[1](#istream.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4296)
When a function is specified
with a type placeholder of *extended-floating-point-type*,
the implementation provides overloads
for all cv-unqualified extended floating-point types ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))
in lieu of *extended-floating-point-type*[.](#istream.general-1.sentence-1)
[🔗](#lib:basic_istream)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_istream : virtual public basic_ios<charT, traits> {public:// types (inherited from [basic_ios](ios "31.5.4Class template basic_­ios[ios]"))using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[istream.cons]](#istream.cons "31.7.5.2.2Constructors"), constructor/destructorexplicit basic_istream(basic_streambuf<charT, traits>* sb); virtual ~basic_istream(); // [[istream.sentry]](#istream.sentry "31.7.5.2.4Class basic_­istream::sentry"), prefix/suffixclass sentry; // [[istream.formatted]](#istream.formatted "31.7.5.3Formatted input functions"), formatted input basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
basic_istream& operator>>(ios_base& (*pf)(ios_base&));
basic_istream& operator>>(bool& n);
basic_istream& operator>>(short& n);
basic_istream& operator>>(unsigned short& n);
basic_istream& operator>>(int& n);
basic_istream& operator>>(unsigned int& n);
basic_istream& operator>>(long& n);
basic_istream& operator>>(unsigned long& n);
basic_istream& operator>>(long long& n);
basic_istream& operator>>(unsigned long long& n);
basic_istream& operator>>(float& f);
basic_istream& operator>>(double& f);
basic_istream& operator>>(long double& f);
basic_istream& operator>>(*extended-floating-point-type*& f);
basic_istream& operator>>(void*& p);
basic_istream& operator>>(basic_streambuf<char_type, traits>* sb); // [[istream.unformatted]](#istream.unformatted "31.7.5.4Unformatted input functions"), unformatted input streamsize gcount() const;
int_type get();
basic_istream& get(char_type& c);
basic_istream& get(char_type* s, streamsize n);
basic_istream& get(char_type* s, streamsize n, char_type delim);
basic_istream& get(basic_streambuf<char_type, traits>& sb);
basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
basic_istream& getline(char_type* s, streamsize n);
basic_istream& getline(char_type* s, streamsize n, char_type delim);
basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
basic_istream& ignore(streamsize n, char_type delim);
int_type peek();
basic_istream& read (char_type* s, streamsize n);
streamsize readsome(char_type* s, streamsize n);
basic_istream& putback(char_type c);
basic_istream& unget(); int sync();
pos_type tellg();
basic_istream& seekg(pos_type);
basic_istream& seekg(off_type, ios_base::seekdir); protected:// [[istream.cons]](#istream.cons "31.7.5.2.2Constructors"), copy/move constructor basic_istream(const basic_istream&) = delete;
basic_istream(basic_istream&& rhs); // [[istream.assign]](#istream.assign "31.7.5.2.3Assignment and swap"), assignment and swap basic_istream& operator=(const basic_istream&) = delete;
basic_istream& operator=(basic_istream&& rhs); void swap(basic_istream& rhs); }; // [[istream.extractors]](#istream.extractors "31.7.5.3.3basic_­istream::operator>>"), character extraction templatestemplate<class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT&); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&); template<class traits> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&); template<class charT, class traits, size_t N> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT(&)[N]); template<class traits, size_t N> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char(&)[N]); template<class traits, size_t N> basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char(&)[N]);}
[2](#istream.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4399)
The class templatebasic_istream defines a number of member function
signatures that assist in reading and interpreting input from sequences
controlled by a stream buffer[.](#istream.general-2.sentence-1)
[3](#istream.general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4406)
Two groups of member function signatures share common properties:
the[*formatted input functions*](#def:formatted_input_functions) (or[*extractors*](#def:extractors))
and the[*unformatted input functions.*](#def:unformatted_input_functions.) Both groups of input functions are described as if they obtain (or[*extract*](#def:extract))
input[*characters*](#def:characters) by callingrdbuf()->sbumpc() orrdbuf()->sgetc()[.](#istream.general-3.sentence-1)
They may use other public members ofistream[.](#istream.general-3.sentence-2)
#### [31.7.5.2.2](#istream.cons) Constructors [[istream.cons]](istream.cons)
[🔗](#lib:basic_istream,constructor)
`explicit basic_istream(basic_streambuf<charT, traits>* sb);
`
[1](#istream.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4434)
*Effects*: Initializes the base class subobject withbasic_ios::init(sb) ([[basic.ios.cons]](basic.ios.cons "31.5.4.2Constructors"))[.](#istream.cons-1.sentence-1)
[2](#istream.cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4439)
*Postconditions*: gcount() == 0[.](#istream.cons-2.sentence-1)
[🔗](#lib:basic_istream,constructor_)
`basic_istream(basic_istream&& rhs);
`
[3](#istream.cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4451)
*Effects*: Default constructs the base class, copies thegcount() from rhs, callsbasic_ios<charT, traits>::move(rhs) to initialize the base
class, and sets the gcount() for rhs to 0[.](#istream.cons-3.sentence-1)
[🔗](#lib:basic_istream,destructor)
`virtual ~basic_istream();
`
[4](#istream.cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4465)
*Remarks*: Does not perform any operations ofrdbuf()[.](#istream.cons-4.sentence-1)
#### [31.7.5.2.3](#istream.assign) Assignment and swap [[istream.assign]](istream.assign)
[🔗](#lib:operator=,basic_istream)
`basic_istream& operator=(basic_istream&& rhs);
`
[1](#istream.assign-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4479)
*Effects*: Equivalent to swap(rhs)[.](#istream.assign-1.sentence-1)
[2](#istream.assign-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4483)
*Returns*: *this[.](#istream.assign-2.sentence-1)
[🔗](#lib:swap,basic_istream)
`void swap(basic_istream& rhs);
`
[3](#istream.assign-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4494)
*Effects*: Calls basic_ios<charT, traits>::swap(rhs)[.](#istream.assign-3.sentence-1)
Exchanges the values returned by gcount() andrhs.gcount()[.](#istream.assign-3.sentence-2)
#### [31.7.5.2.4](#istream.sentry) Class basic_istream::sentry [[istream.sentry]](istream.sentry)
[🔗](#lib:basic_istream::sentry)
namespace std {template<class charT, class traits>class basic_istream<charT, traits>::sentry {bool *ok_*; // *exposition only*public:explicit sentry(basic_istream& is, bool noskipws = false); ~sentry(); explicit operator bool() const { return *ok_*; } sentry(const sentry&) = delete;
sentry& operator=(const sentry&) = delete; };}
[1](#istream.sentry-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4522)
The classsentry defines a class that is responsible for doing exception safe prefix and suffix
operations[.](#istream.sentry-1.sentence-1)
[🔗](#lib:sentry,constructor)
`explicit sentry(basic_istream& is, bool noskipws = false);
`
[2](#istream.sentry-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4536)
*Effects*: Ifis.good() isfalse,
calls is.setstate(failbit)[.](#istream.sentry-2.sentence-1)
Otherwise,
prepares for formatted or
unformatted input[.](#istream.sentry-2.sentence-2)
First, ifis.tie() is not a null pointer, the
function callsis.tie()->flush() to synchronize the output sequence with any associated external
C stream[.](#istream.sentry-2.sentence-3)
Except that this call can be suppressed if the put area ofis.tie() is empty[.](#istream.sentry-2.sentence-4)
Further an implementation is allowed to defer the call toflush until a
call ofis.rdbuf()->underflow() occurs[.](#istream.sentry-2.sentence-5)
If no such call occurs before thesentry object is destroyed, the call toflush may be eliminated entirely[.](#istream.sentry-2.sentence-6)[272](#footnote-272 "This will be possible only in functions that are part of the library. The semantics of the constructor used in user code is as specified.")
If noskipws is zero andis.flags() & ios_base::skipws is nonzero, the function extracts and discards each character as long as
the next available input character c is a whitespace character[.](#istream.sentry-2.sentence-7)
Ifis.rdbuf()->sbumpc() oris.rdbuf()->sgetc() returnstraits::eof(),
the function callssetstate(failbit | eofbit) (which may throwios_base::failure)[.](#istream.sentry-2.sentence-8)
[3](#istream.sentry-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4587)
*Remarks*: The constructorexplicit sentry(basic_istream& is, bool noskipws = false) uses the currently imbued locale in is,
to determine whether the next input character is
whitespace or not[.](#istream.sentry-3.sentence-1)
[4](#istream.sentry-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4597)
To decide if the character c is a whitespace character,
the constructor performs as if it executes the following code fragment:const ctype<charT>& ctype = use_facet<ctype<charT>>(is.getloc());if (ctype.is(ctype.space, c) != 0)// c is a whitespace character.
[5](#istream.sentry-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4606)
If, after any preparation is completed,is.good() istrue,*ok_* != false otherwise,*ok_* == false[.](#istream.sentry-5.sentence-1)
During preparation, the constructor may callsetstate(failbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#istream.sentry-5.sentence-2)[273](#footnote-273 "The sentry constructor and destructor can also perform additional implementation-dependent operations.")
[🔗](#lib:sentry,destructor)
`~sentry();
`
[6](#istream.sentry-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4635)
*Effects*: None[.](#istream.sentry-6.sentence-1)
[🔗](#lib:operator_bool,basic_istream::sentry)
`explicit operator bool() const;
`
[7](#istream.sentry-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4646)
*Returns*: *ok_*[.](#istream.sentry-7.sentence-1)
[272)](#footnote-272)[272)](#footnoteref-272)
This will be possible only in functions
that are part of the library[.](#footnote-272.sentence-1)
The semantics of the constructor used in user code is as specified[.](#footnote-272.sentence-2)
[273)](#footnote-273)[273)](#footnoteref-273)
Thesentry constructor and destructor
can also perform additionalimplementation-dependent operations[.](#footnote-273.sentence-1)
#### [31.7.5.3](#istream.formatted) Formatted input functions [[istream.formatted]](istream.formatted)
#### [31.7.5.3.1](#istream.formatted.reqmts) Common requirements [[istream.formatted.reqmts]](istream.formatted.reqmts)
[1](#istream.formatted.reqmts-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4655)
Each formatted input function begins execution by constructing
an object of type ios_base::iostate, termed the local error state, and
initializing it to ios_base::goodbit[.](#istream.formatted.reqmts-1.sentence-1)
It then creates an object of classsentry with thenoskipws (second) argumentfalse[.](#istream.formatted.reqmts-1.sentence-2)
If thesentry object returnstrue,
when converted to a value of typebool,
the function endeavors
to obtain the requested input[.](#istream.formatted.reqmts-1.sentence-3)
Otherwise,
if the sentry constructor exits by throwing an exception or
if the sentry object produces false when converted to a value of type bool,
the function returns without attempting to obtain any input[.](#istream.formatted.reqmts-1.sentence-4)
If rdbuf()->sbumpc() or rdbuf()->sgetc() returns traits::eof(), thenios_base::eofbit is set in the local error state and
the input function stops trying to obtain the requested input[.](#istream.formatted.reqmts-1.sentence-5)
If an exception is thrown during input thenios_base::badbit is set in the local error state,*this's error state is set to the local error state, and
the exception is rethrown if (exceptions() & badbit) != 0[.](#istream.formatted.reqmts-1.sentence-6)
After extraction is done, the input function calls setstate, which
sets *this's error state to the local error state, and
may throw an exception[.](#istream.formatted.reqmts-1.sentence-7)
In any case, the formatted input function destroys thesentry object[.](#istream.formatted.reqmts-1.sentence-8)
If no exception has been thrown, it returns*this[.](#istream.formatted.reqmts-1.sentence-9)
#### [31.7.5.3.2](#istream.formatted.arithmetic) Arithmetic extractors [[istream.formatted.arithmetic]](istream.formatted.arithmetic)
[🔗](#lib:operator%3e%3e,basic_istream)
`basic_istream& operator>>(unsigned short& val);
basic_istream& operator>>(unsigned int& val);
basic_istream& operator>>(long& val);
basic_istream& operator>>(unsigned long& val);
basic_istream& operator>>(long long& val);
basic_istream& operator>>(unsigned long long& val);
basic_istream& operator>>(float& val);
basic_istream& operator>>(double& val);
basic_istream& operator>>(long double& val);
basic_istream& operator>>(bool& val);
basic_istream& operator>>(void*& val);
`
[1](#istream.formatted.arithmetic-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4713)
As in the case of the inserters, these extractors depend on the
locale's[num_get<>](locale.num.get "28.3.4.3.2Class template num_­get[locale.num.get]") object to perform parsing the input
stream data[.](#istream.formatted.arithmetic-1.sentence-1)
These extractors behave as formatted input functions (as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#istream.formatted.arithmetic-1.sentence-2)
After a sentry object is constructed, the
conversion occurs as if performed by the following code fragment,
where state represents the input function's local error state:using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
use_facet<numget>(loc).get(*this, 0, *this, state, val);
In the above fragment,loc stands for the private member of thebasic_ios class[.](#istream.formatted.arithmetic-1.sentence-4)
[*Note [1](#istream.formatted.arithmetic-note-1)*:
The first argument provides an object of theistreambuf_iterator class which is an iterator pointed to an input stream[.](#istream.formatted.arithmetic-1.sentence-5)
It bypasses istreams and uses streambufs directly[.](#istream.formatted.arithmetic-1.sentence-6)
— *end note*]
Classlocale relies on this
type as its interface toistream,
so that it does not need to depend directly onistream[.](#istream.formatted.arithmetic-1.sentence-7)
[🔗](#lib:operator%3e%3e,basic_istream_)
`basic_istream& operator>>(short& val);
`
[2](#istream.formatted.arithmetic-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4751)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<short>::min()) { state |= ios_base::failbit;
val = numeric_limits<short>::min();} else if (numeric_limits<short>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<short>::max();} else val = static_cast<short>(lval);
[🔗](#lib:operator%3e%3e,basic_istream__)
`basic_istream& operator>>(int& val);
`
[3](#istream.formatted.arithmetic-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4775)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<int>::min()) { state |= ios_base::failbit;
val = numeric_limits<int>::min();} else if (numeric_limits<int>::max() < lval) { state |= ios_base::failbit;
val = numeric_limits<int>::max();} else val = static_cast<int>(lval);
[🔗](#istream.formatted.arithmetic-itemdecl:4)
`basic_istream& operator>>(extended-floating-point-type& val);
`
[4](#istream.formatted.arithmetic-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4798)
If
the floating-point conversion rank of *extended-floating-point-type* is not less than or equal to that of long double,
then an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#istream.formatted.arithmetic-4.sentence-1)
[5](#istream.formatted.arithmetic-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4806)
Otherwise, let FP be a standard floating-point type:
- [(5.1)](#istream.formatted.arithmetic-5.1)
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of float,
then FP is float,
- [(5.2)](#istream.formatted.arithmetic-5.2)
otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
then FP is double,
- [(5.3)](#istream.formatted.arithmetic-5.3)
otherwise, FP is long double[.](#istream.formatted.arithmetic-5.sentence-1)
[6](#istream.formatted.arithmetic-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4822)
The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
FP fval;
use_facet<numget>(loc).get(*this, 0, *this, state, fval);if (fval < -numeric_limits<*extended-floating-point-type*>::max()) { state |= ios_base::failbit;
val = -numeric_limits<*extended-floating-point-type*>::max();} else if (numeric_limits<*extended-floating-point-type*>::max() < fval) { state |= ios_base::failbit;
val = numeric_limits<*extended-floating-point-type*>::max();} else { val = static_cast<*extended-floating-point-type*>(fval);}
[*Note [2](#istream.formatted.arithmetic-note-2)*:
When the extended floating-point type has
a floating-point conversion rank
that is not equal to the rank of any standard floating-point type,
then double rounding during the conversion can result in inaccurate results[.](#istream.formatted.arithmetic-6.sentence-1)
from_chars can be used in situations
where maximum accuracy is important[.](#istream.formatted.arithmetic-6.sentence-2)
— *end note*]
#### [31.7.5.3.3](#istream.extractors) basic_istream::operator>> [[istream.extractors]](istream.extractors)
[🔗](#lib:operator%3e%3e,basic_istream___)
`basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
`
[1](#istream.extractors-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4857)
*Effects*: None[.](#istream.extractors-1.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-1.sentence-2)
[2](#istream.extractors-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4863)
*Returns*: pf(*this)[.](#istream.extractors-2.sentence-1)
[274](#footnote-274 "See, for example, the function signature ws(basic_­istream&amp;) ([istream.manip]).")
[🔗](#lib:operator%3e%3e,basic_istream____)
`basic_istream& operator>>(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
`
[3](#istream.extractors-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4879)
*Effects*: Callspf(*this)[.](#istream.extractors-3.sentence-1)
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-3.sentence-2)
[4](#istream.extractors-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4886)
*Returns*: *this[.](#istream.extractors-4.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream_____)
`basic_istream& operator>>(ios_base& (*pf)(ios_base&));
`
[5](#istream.extractors-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4897)
*Effects*: Callspf(*this)[.](#istream.extractors-5.sentence-1)[275](#footnote-275 "See, for example, the function signature dec(ios_­base&amp;) ([basefield.manip]).")
This extractor does not behave as a formatted input function
(as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))[.](#istream.extractors-5.sentence-2)
[6](#istream.extractors-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4908)
*Returns*: *this[.](#istream.extractors-6.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream______)
`template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char (&s)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char (&s)[N]);
`
[7](#istream.extractors-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4924)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))
of in[.](#istream.extractors-7.sentence-1)
After asentry object is constructed,operator>> extracts characters and stores them intos[.](#istream.extractors-7.sentence-2)
Ifwidth() is greater than zero, n ismin(size_t(width()), N)[.](#istream.extractors-7.sentence-3)
Otherwise n is N[.](#istream.extractors-7.sentence-4)
n is the maximum number of characters stored[.](#istream.extractors-7.sentence-5)
[8](#istream.extractors-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4941)
Characters are extracted and stored until any of the following occurs:
- [(8.1)](#istream.extractors-8.1)
n - 1 characters are stored;
- [(8.2)](#istream.extractors-8.2)
end of file occurs on the input sequence;
- [(8.3)](#istream.extractors-8.3)
letting ct be use_facet<ctype<charT>>(in.getloc()),ct.is(ct.space, c) is true[.](#istream.extractors-8.sentence-1)
[9](#istream.extractors-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4950)
operator>> then stores a null byte
(charT())
in the next position, which may be the first position if no characters
were extracted[.](#istream.extractors-9.sentence-1)
operator>> then callswidth(0)[.](#istream.extractors-9.sentence-2)
[10](#istream.extractors-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4960)
If the function extracted no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-10.sentence-1)
[11](#istream.extractors-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4965)
*Returns*: in[.](#istream.extractors-11.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream_______)
`template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& in, charT& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
`
[12](#istream.extractors-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4981)
*Effects*: Behaves like a formatted input member (as described in [[istream.formatted.reqmts]](#istream.formatted.reqmts "31.7.5.3.1Common requirements"))
of in[.](#istream.extractors-12.sentence-1)
A character is extracted from in, if one is available, and stored in c[.](#istream.extractors-12.sentence-2)
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-12.sentence-3)
[13](#istream.extractors-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4990)
*Returns*: in[.](#istream.extractors-13.sentence-1)
[🔗](#lib:operator%3e%3e,basic_istream________)
`basic_istream& operator>>(basic_streambuf<charT, traits>* sb);
`
[14](#istream.extractors-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5001)
*Effects*: Behaves as an [unformatted input function](#istream.unformatted "31.7.5.4Unformatted input functions[istream.unformatted]")[.](#istream.extractors-14.sentence-1)
If sb is null, callssetstate(failbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))[.](#istream.extractors-14.sentence-2)
After a sentry object is constructed, extracts
characters from*this and inserts them in the output sequence controlled by sb[.](#istream.extractors-14.sentence-3)
Characters are extracted and inserted until any of the following occurs:
- [(14.1)](#istream.extractors-14.1)
end-of-file occurs on the input sequence;
- [(14.2)](#istream.extractors-14.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(14.3)](#istream.extractors-14.3)
an exception occurs (in which case the exception is caught)[.](#istream.extractors-14.sentence-4)
[15](#istream.extractors-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5023)
If the function inserts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.extractors-15.sentence-1)
[16](#istream.extractors-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5028)
*Returns*: *this[.](#istream.extractors-16.sentence-1)
[274)](#footnote-274)[274)](#footnoteref-274)
See, for example, the function signaturews(basic_istream&) ([[istream.manip]](#istream.manip "31.7.5.5Standard basic_­istream manipulators"))[.](#footnote-274.sentence-1)
[275)](#footnote-275)[275)](#footnoteref-275)
See, for example, the function signaturedec(ios_base&) ([[basefield.manip]](basefield.manip "31.5.5.3basefield manipulators"))[.](#footnote-275.sentence-1)
#### [31.7.5.4](#istream.unformatted) Unformatted input functions [[istream.unformatted]](istream.unformatted)
[1](#istream.unformatted-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5035)
Each unformatted input function begins execution by constructing
an object of type ios_base::iostate, termed the local error state, and
initializing it to ios_base::goodbit[.](#istream.unformatted-1.sentence-1)
It then creates an object of classsentry with the default argumentnoskipws (second) argumenttrue[.](#istream.unformatted-1.sentence-2)
If thesentry object returnstrue,
when converted to a value of typebool,
the function endeavors
to obtain the requested input[.](#istream.unformatted-1.sentence-3)
Otherwise, if the sentry constructor exits by throwing an exception or if
the sentry object produces false, when converted to a value of typebool,
the function returns without attempting to obtain any input[.](#istream.unformatted-1.sentence-4)
In either case the number of extracted characters is set to 0;
unformatted input functions taking a character array of nonzero size as
an argument shall also store a null character (usingcharT())
in the first location of the array[.](#istream.unformatted-1.sentence-5)
If rdbuf()->sbumpc() or rdbuf()->sgetc() returns traits::eof(), thenios_base::eofbit is set in the local error state and
the input function stops trying to obtain the requested input[.](#istream.unformatted-1.sentence-6)
If an exception is thrown during input thenios_base::badbit is set in the local error state,*this's error state is set to the local error state, and
the exception is rethrown if (exceptions() & badbit) != 0[.](#istream.unformatted-1.sentence-7)
If no exception has been thrown it
stores the number of characters extracted
in a member object[.](#istream.unformatted-1.sentence-8)
After extraction is done, the input function calls setstate, which
sets *this's error state to the local error state, and
may throw an exception[.](#istream.unformatted-1.sentence-9)
In any event thesentry object
is destroyed before leaving the unformatted input function[.](#istream.unformatted-1.sentence-10)
[🔗](#lib:gcount,basic_istream)
`streamsize gcount() const;
`
[2](#istream.unformatted-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5087)
*Effects*: None[.](#istream.unformatted-2.sentence-1)
This member function does not behave as an unformatted
input function (as described above)[.](#istream.unformatted-2.sentence-2)
[3](#istream.unformatted-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5093)
*Returns*: The number of characters
extracted by the last unformatted input member function called for the object[.](#istream.unformatted-3.sentence-1)
If the number cannot be represented,
returns numeric_limits<streamsize>::max()[.](#istream.unformatted-3.sentence-2)
[🔗](#lib:get,basic_istream)
`int_type get();
`
[4](#istream.unformatted-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5107)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-4.sentence-1)
After constructing a sentry object, extracts
a character c, if one is available[.](#istream.unformatted-4.sentence-2)
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.unformatted-4.sentence-3)
[5](#istream.unformatted-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5117)
*Returns*: c if available,
otherwisetraits::eof()[.](#istream.unformatted-5.sentence-1)
[🔗](#lib:get,basic_istream_)
`basic_istream& get(char_type& c);
`
[6](#istream.unformatted-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5130)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-6.sentence-1)
After constructing a sentry object, extracts
a character, if one is available, and assigns it to c[.](#istream.unformatted-6.sentence-2)[276](#footnote-276 "Note that this function is not overloaded on types signed char and unsigned char.")
Otherwise,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.unformatted-6.sentence-3)
[7](#istream.unformatted-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5147)
*Returns*: *this[.](#istream.unformatted-7.sentence-1)
[🔗](#lib:get,basic_istream__)
`basic_istream& get(char_type* s, streamsize n, char_type delim);
`
[8](#istream.unformatted-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5158)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-8.sentence-1)
After constructing a sentry object, extracts
characters and stores them
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-8.sentence-2)[277](#footnote-277 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until any of the following occurs:
- [(8.1)](#istream.unformatted-8.1)
n is less than one or n - 1 characters are stored;
- [(8.2)](#istream.unformatted-8.2)
end-of-file occurs on the input sequence;
- [(8.3)](#istream.unformatted-8.3)
traits::eq(c, delim) for the next available input
character c (in which case c is not extracted)[.](#istream.unformatted-8.sentence-3)
[9](#istream.unformatted-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5186)
If the function stores no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.unformatted-9.sentence-1)
In any case, if n is greater than zero it then stores a null character
into the next successive location of the array[.](#istream.unformatted-9.sentence-2)
[10](#istream.unformatted-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5193)
*Returns*: *this[.](#istream.unformatted-10.sentence-1)
[🔗](#lib:get,basic_istream___)
`basic_istream& get(char_type* s, streamsize n);
`
[11](#istream.unformatted-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5204)
*Effects*: Callsget(s, n, widen('\n'))[.](#istream.unformatted-11.sentence-1)
[12](#istream.unformatted-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5209)
*Returns*: Value returned by the call[.](#istream.unformatted-12.sentence-1)
[🔗](#lib:get,basic_istream____)
`basic_istream& get(basic_streambuf<char_type, traits>& sb, char_type delim);
`
[13](#istream.unformatted-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5220)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-13.sentence-1)
After constructing a sentry object, extracts
characters and inserts them
in the output sequence controlled bysb[.](#istream.unformatted-13.sentence-2)
Characters are extracted and inserted until any of the following occurs:
- [(13.1)](#istream.unformatted-13.1)
end-of-file occurs on the input sequence;
- [(13.2)](#istream.unformatted-13.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(13.3)](#istream.unformatted-13.3)
traits::eq(c, delim) for the next available input
character c (in which case c is not extracted);
- [(13.4)](#istream.unformatted-13.4)
an exception occurs
(in which case, the exception is caught but not rethrown)[.](#istream.unformatted-13.sentence-3)
[14](#istream.unformatted-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5244)
If the function inserts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.unformatted-14.sentence-1)
[15](#istream.unformatted-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5249)
*Returns*: *this[.](#istream.unformatted-15.sentence-1)
[🔗](#lib:get,basic_istream_____)
`basic_istream& get(basic_streambuf<char_type, traits>& sb);
`
[16](#istream.unformatted-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5260)
*Effects*: Callsget(sb, widen('\n'))[.](#istream.unformatted-16.sentence-1)
[17](#istream.unformatted-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5265)
*Returns*: Value returned by the call[.](#istream.unformatted-17.sentence-1)
[🔗](#lib:getline,basic_istream)
`basic_istream& getline(char_type* s, streamsize n, char_type delim);
`
[18](#istream.unformatted-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5276)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-18.sentence-1)
After constructing a sentry object, extracts
characters and stores them
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-18.sentence-2)[278](#footnote-278 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until one of the following occurs:
| [1.](#istream.unformatted-18.1) | end-of-file occurs on the input sequence; |
| --- | --- |
| [2.](#istream.unformatted-18.2) | traits::eq(c, delim) for the next available input character c (in which case the input character is extracted but not stored);[279](#footnote-279 "Since the final input character is “extracted”, it is counted in the gcount(), even though it is not stored.") |
| [3.](#istream.unformatted-18.3) | n is less than one or n - 1 characters are stored (in which case the function calls setstate(failbit))[.](#istream.unformatted-18.sentence-3) |
[19](#istream.unformatted-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5313)
These conditions are tested in the order shown[.](#istream.unformatted-19.sentence-1)[280](#footnote-280 "This allows an input line which exactly fills the buffer, without setting failbit. This is different behavior than the historical AT&amp;T implementation.")
[20](#istream.unformatted-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5322)
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
before setstate is called[.](#istream.unformatted-20.sentence-1)[281](#footnote-281 "This implies an empty input line will not cause failbit to be set.")
[21](#istream.unformatted-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5333)
In any case, if n is greater than zero, it then stores a null character
(usingcharT())
into the next successive location of the array[.](#istream.unformatted-21.sentence-1)
[22](#istream.unformatted-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5339)
*Returns*: *this[.](#istream.unformatted-22.sentence-1)
[23](#istream.unformatted-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5343)
[*Example [1](#istream.unformatted-example-1)*: #include <iostream>int main() {using namespace std; const int line_buffer_size = 100; char buffer[line_buffer_size]; int line_number = 0; while (cin.getline(buffer, line_buffer_size, '\n') || cin.gcount()) {int count = cin.gcount(); if (cin.eof()) cout << "Partial final line"; // cin.fail() is falseelse if (cin.fail()) { cout << "Partial long line";
cin.clear(cin.rdstate() & ~ios_base::failbit); } else { count--; // Don't include newline in count cout << "Line " << ++line_number; } cout << " (" << count << " chars): " << buffer << endl; }} — *end example*]
[🔗](#lib:getline,basic_istream_)
`basic_istream& getline(char_type* s, streamsize n);
`
[24](#istream.unformatted-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5378)
*Returns*: getline(s, n, widen('\n'))[.](#istream.unformatted-24.sentence-1)
[🔗](#lib:ignore,basic_istream)
`basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof());
`
[25](#istream.unformatted-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5389)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-25.sentence-1)
After constructing a sentry object, extracts
characters and discards them[.](#istream.unformatted-25.sentence-2)
Characters are extracted until any of the following occurs:
- [(25.1)](#istream.unformatted-25.1)
n != [numeric_limits<streamsize>::max()](numeric.limits.members#lib:numeric_limits,max "17.3.5.2numeric_­limits members[numeric.limits.members]")numeric.limits andn characters have been extracted so far;
- [(25.2)](#istream.unformatted-25.2)
end-of-file occurs on the input sequence
(in which case the function callssetstate(eofbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")));
- [(25.3)](#istream.unformatted-25.3)
traits::eq_int_type(traits::to_int_type(c), delim) for the next available input character c (in which case c is extracted)[.](#istream.unformatted-25.sentence-3)
[*Note [1](#istream.unformatted-note-1)*:
The last condition will never occur iftraits::eq_int_type(delim, traits::eof())[.](#istream.unformatted-25.sentence-4)
— *end note*]
[26](#istream.unformatted-26)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5417)
*Returns*: *this[.](#istream.unformatted-26.sentence-1)
[🔗](#lib:ignore,basic_istream_)
`basic_istream& ignore(streamsize n, char_type delim);
`
[27](#istream.unformatted-27)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5428)
*Constraints*: is_same_v<char_type, char> is true[.](#istream.unformatted-27.sentence-1)
[28](#istream.unformatted-28)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5432)
*Effects*: Equivalent to: return ignore(n, traits::to_int_type(delim));
[🔗](#lib:peek,basic_istream)
`int_type peek();
`
[29](#istream.unformatted-29)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5443)
*Effects*: Behaves as an unformatted input function
(as described above)[.](#istream.unformatted-29.sentence-1)
After constructing a sentry object, reads but does not extract
the current input character[.](#istream.unformatted-29.sentence-2)
[30](#istream.unformatted-30)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5450)
*Returns*: traits::eof() ifgood() isfalse[.](#istream.unformatted-30.sentence-1)
Otherwise, returnsrdbuf()->sgetc()[.](#istream.unformatted-30.sentence-2)
[🔗](#lib:read,basic_istream)
`basic_istream& read(char_type* s, streamsize n);
`
[31](#istream.unformatted-31)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5467)
*Effects*: Behaves as an unformatted input function (as described above)[.](#istream.unformatted-31.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#istream.unformatted-31.sentence-2)
Otherwise extracts characters and stores them
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-31.sentence-3)[282](#footnote-282 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are extracted and stored until either of the following occurs:
- [(31.1)](#istream.unformatted-31.1)
n characters are stored;
- [(31.2)](#istream.unformatted-31.2)
end-of-file occurs on the input sequence
(in which case the function callssetstate(failbit | eofbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#istream.unformatted-31.sentence-4)
[32](#istream.unformatted-32)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5498)
*Returns*: *this[.](#istream.unformatted-32.sentence-1)
[🔗](#lib:readsome,basic_istream)
`streamsize readsome(char_type* s, streamsize n);
`
[33](#istream.unformatted-33)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5509)
*Effects*: Behaves as an unformatted input function (as described above)[.](#istream.unformatted-33.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#istream.unformatted-33.sentence-2)
Otherwise extracts characters and stores them
into successive locations of an array whose first element is designated bys[.](#istream.unformatted-33.sentence-3)
Ifrdbuf()->in_avail() == -1,
callssetstate(eofbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions"))),
and extracts no characters;
- [(33.1)](#istream.unformatted-33.1)
Ifrdbuf()->in_avail() == 0,
extracts no characters
- [(33.2)](#istream.unformatted-33.2)
Ifrdbuf()->in_avail() > 0,
extractsmin(rdbuf()->in_avail(), n))[.](#istream.unformatted-33.sentence-4)
[34](#istream.unformatted-34)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5541)
*Returns*: The number of characters extracted[.](#istream.unformatted-34.sentence-1)
[🔗](#lib:putback,basic_istream)
`basic_istream& putback(char_type c);
`
[35](#istream.unformatted-35)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5552)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit[.](#istream.unformatted-35.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#istream.unformatted-35.sentence-2)
Ifrdbuf() is not null, callsrdbuf()->sputbackc(c)[.](#istream.unformatted-35.sentence-3)
Ifrdbuf() is null, or ifsputbackc returnstraits::eof(),
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#istream.unformatted-35.sentence-4)
[*Note [2](#istream.unformatted-note-2)*:
This
function extracts no characters, so the value returned by the next call togcount() is 0[.](#istream.unformatted-35.sentence-5)
— *end note*]
[36](#istream.unformatted-36)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5583)
*Returns*: *this[.](#istream.unformatted-36.sentence-1)
[🔗](#lib:unget,basic_istream)
`basic_istream& unget();
`
[37](#istream.unformatted-37)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5594)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit[.](#istream.unformatted-37.sentence-1)
After constructing
a sentry object, if!good() callssetstate(failbit) which may throw an exception,
and return[.](#istream.unformatted-37.sentence-2)
Ifrdbuf() is not null, callsrdbuf()->sungetc()[.](#istream.unformatted-37.sentence-3)
Ifrdbuf() is null, or ifsungetc returnstraits::eof(),
callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#istream.unformatted-37.sentence-4)
[*Note [3](#istream.unformatted-note-3)*:
This
function extracts no characters, so the value returned by the next call togcount() is 0[.](#istream.unformatted-37.sentence-5)
— *end note*]
[38](#istream.unformatted-38)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5625)
*Returns*: *this[.](#istream.unformatted-38.sentence-1)
[🔗](#lib:sync,basic_istream)
`int sync();
`
[39](#istream.unformatted-39)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5636)
*Effects*: Behaves as an unformatted input function (as described above), except that it does not
count the number of characters extracted and does not affect the
value returned by subsequent calls togcount()[.](#istream.unformatted-39.sentence-1)
After constructing
a sentry object, ifrdbuf() is a null pointer, returns -1[.](#istream.unformatted-39.sentence-2)
Otherwise, callsrdbuf()->pubsync() and, if that function returns -1 callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")),
and returns-1[.](#istream.unformatted-39.sentence-3)
Otherwise, returns zero[.](#istream.unformatted-39.sentence-4)
[🔗](#lib:tellg,basic_istream)
`pos_type tellg();
`
[40](#istream.unformatted-40)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5664)
*Effects*: Behaves as an unformatted input function (as described above), except that it does not count
the number of characters extracted and does not affect the value
returned by subsequent calls togcount()[.](#istream.unformatted-40.sentence-1)
[41](#istream.unformatted-41)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5671)
*Returns*: After constructing a sentry object, iffail() != false,
returnspos_type(-1) to indicate failure[.](#istream.unformatted-41.sentence-1)
Otherwise, returnsrdbuf()->pubseekoff(0, cur, in)[.](#istream.unformatted-41.sentence-2)
[🔗](#lib:seekg,basic_istream)
`basic_istream& seekg(pos_type pos);
`
[42](#istream.unformatted-42)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5688)
*Effects*: Behaves as an unformatted input function (as described above), except that
the function first clears eofbit,
it does not count
the number of characters extracted, and it does not affect the value
returned by subsequent calls togcount()[.](#istream.unformatted-42.sentence-1)
After constructing a sentry object, iffail() != true,
executesrdbuf()->pubseekpos(pos, ios_base::in)[.](#istream.unformatted-42.sentence-2)
In case of failure, the function callssetstate(failbit) (which may throwios_base::failure)[.](#istream.unformatted-42.sentence-3)
[43](#istream.unformatted-43)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5705)
*Returns*: *this[.](#istream.unformatted-43.sentence-1)
[🔗](#lib:seekg,basic_istream_)
`basic_istream& seekg(off_type off, ios_base::seekdir dir);
`
[44](#istream.unformatted-44)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5716)
*Effects*: Behaves as an unformatted input function (as described above), except that the function first clears eofbit,
does not count the number of characters extracted, and
does not affect the value returned by subsequent calls to gcount()[.](#istream.unformatted-44.sentence-1)
After constructing a sentry object, iffail() != true,
executesrdbuf()->pubseekoff(off, dir, ios_base::in)[.](#istream.unformatted-44.sentence-2)
In case of failure, the function calls setstate(failbit) (which may throwios_base::failure)[.](#istream.unformatted-44.sentence-3)
[45](#istream.unformatted-45)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5728)
*Returns*: *this[.](#istream.unformatted-45.sentence-1)
[276)](#footnote-276)[276)](#footnoteref-276)
Note
that this function is not overloaded on typessigned char andunsigned char[.](#footnote-276.sentence-1)
[277)](#footnote-277)[277)](#footnoteref-277)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-277.sentence-1)
[278)](#footnote-278)[278)](#footnoteref-278)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-278.sentence-1)
[279)](#footnote-279)[279)](#footnoteref-279)
Since
the final input character is “extracted”,
it is counted in thegcount(),
even though it is not stored[.](#footnote-279.sentence-1)
[280)](#footnote-280)[280)](#footnoteref-280)
This allows an input
line which exactly fills the buffer, without settingfailbit[.](#footnote-280.sentence-1)
This is different behavior than the historical AT&T implementation[.](#footnote-280.sentence-2)
[281)](#footnote-281)[281)](#footnoteref-281)
This implies an
empty input line will not causefailbit to be set[.](#footnote-281.sentence-1)
[282)](#footnote-282)[282)](#footnoteref-282)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-282.sentence-1)
#### [31.7.5.5](#istream.manip) Standard basic_istream manipulators [[istream.manip]](istream.manip)
[1](#istream.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5735)
Each instantiation of the function template
specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#istream.manip-1.sentence-1)
[🔗](#lib:ws_)
`template<class charT, class traits>
basic_istream<charT, traits>& ws(basic_istream<charT, traits>& is);
`
[2](#istream.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5747)
*Effects*: Behaves as an [unformatted input function](#istream.unformatted "31.7.5.4Unformatted input functions[istream.unformatted]"), except that it does not count the number of characters extracted and
does not affect the value returned by subsequent calls to is.gcount()[.](#istream.manip-2.sentence-1)
After
constructing a sentry object extracts characters as long as the next available
character c is whitespace or until there are no more characters in the sequence[.](#istream.manip-2.sentence-2)
Whitespace characters are distinguished with the same criterion as used by[sentry::sentry](#istream.sentry "31.7.5.2.4Class basic_­istream::sentry[istream.sentry]")[.](#istream.manip-2.sentence-3)
Ifws stops extracting characters because there are no more available it setseofbit,
but notfailbit[.](#istream.manip-2.sentence-4)
[3](#istream.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5762)
*Returns*: is[.](#istream.manip-3.sentence-1)
#### [31.7.5.6](#istream.rvalue) Rvalue stream extraction [[istream.rvalue]](istream.rvalue)
[🔗](#lib:operator%3e%3e,basic_istream_________)
`template<class Istream, class T>
Istream&& operator>>(Istream&& is, T&& x);
`
[1](#istream.rvalue-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5776)
*Constraints*: The expression is >> std::forward<T>(x) is well-formed
when treated as an [unevaluated operand](expr.context#def:unevaluated_operand "7.2.3Context dependence[expr.context]") andIstream is publicly and unambiguously derived from ios_base[.](#istream.rvalue-1.sentence-1)
[2](#istream.rvalue-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5782)
*Effects*: Equivalent to:is >> std::forward<T>(x);return std::move(is);
#### [31.7.5.7](#iostreamclass) Class template basic_iostream [[iostreamclass]](iostreamclass)
#### [31.7.5.7.1](#iostreamclass.general) General [[iostreamclass.general]](iostreamclass.general)
[🔗](#lib:basic_iostream)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_iostream : public basic_istream<charT, traits>, public basic_ostream<charT, traits> {public:using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[iostream.cons]](#iostream.cons "31.7.5.7.2Constructors"), constructorexplicit basic_iostream(basic_streambuf<charT, traits>* sb); // [[iostream.dest]](#iostream.dest "31.7.5.7.3Destructor"), destructorvirtual ~basic_iostream(); protected:// [[iostream.cons]](#iostream.cons "31.7.5.7.2Constructors"), constructor basic_iostream(const basic_iostream&) = delete;
basic_iostream(basic_iostream&& rhs); // [[iostream.assign]](#iostream.assign "31.7.5.7.4Assignment and swap"), assignment and swap basic_iostream& operator=(const basic_iostream&) = delete;
basic_iostream& operator=(basic_iostream&& rhs); void swap(basic_iostream& rhs); };}
[1](#iostreamclass.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5828)
The class templatebasic_iostream inherits a number of functions that allow reading input and writing output to
sequences controlled by a stream buffer[.](#iostreamclass.general-1.sentence-1)
#### [31.7.5.7.2](#iostream.cons) Constructors [[iostream.cons]](iostream.cons)
[🔗](#lib:basic_iostream,constructor)
`explicit basic_iostream(basic_streambuf<charT, traits>* sb);
`
[1](#iostream.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5842)
*Effects*: Initializes the base class subobjects withbasic_istream<charT, traits>(sb) ([[istream]](#istream "31.7.5.2Class template basic_­istream"))
and[basic_ostream<charT, traits>(sb)](#ostream "31.7.6.2Class template basic_­ostream[ostream]")[.](#iostream.cons-1.sentence-1)
[2](#iostream.cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5849)
*Postconditions*: rdbuf() == sb andgcount() == 0[.](#iostream.cons-2.sentence-1)
[🔗](#lib:basic_iostream,constructor_)
`basic_iostream(basic_iostream&& rhs);
`
[3](#iostream.cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5862)
*Effects*: Move constructs from the rvalue rhs by
constructing the basic_istream base class withstd::move(rhs)[.](#iostream.cons-3.sentence-1)
#### [31.7.5.7.3](#iostream.dest) Destructor [[iostream.dest]](iostream.dest)
[🔗](#lib:basic_iostream,destructor)
`virtual ~basic_iostream();
`
[1](#iostream.dest-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5877)
*Remarks*: Does not perform any operations onrdbuf()[.](#iostream.dest-1.sentence-1)
#### [31.7.5.7.4](#iostream.assign) Assignment and swap [[iostream.assign]](iostream.assign)
[🔗](#lib:operator=,basic_iostream)
`basic_iostream& operator=(basic_iostream&& rhs);
`
[1](#iostream.assign-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5891)
*Effects*: Equivalent to swap(rhs)[.](#iostream.assign-1.sentence-1)
[🔗](#lib:swap,basic_iostream)
`void swap(basic_iostream& rhs);
`
[2](#iostream.assign-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5902)
*Effects*: Calls basic_istream<charT, traits>::swap(rhs)[.](#iostream.assign-2.sentence-1)
### [31.7.6](#output.streams) Output streams [[output.streams]](output.streams)
#### [31.7.6.1](#output.streams.general) General [[output.streams.general]](output.streams.general)
[1](#output.streams.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5912)
The header [<ostream>](#header:%3costream%3e "31.7.2Header <ostream> synopsis[ostream.syn]") defines a class template
and several function templates that control output to a stream buffer,
along with a function template that inserts into stream rvalues[.](#output.streams.general-1.sentence-1)
#### [31.7.6.2](#ostream) Class template basic_ostream [[ostream]](ostream)
#### [31.7.6.2.1](#ostream.general) General [[ostream.general]](ostream.general)
[1](#ostream.general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L5921)
When a function has
a parameter type *extended-floating-point-type*,
the implementation provides overloads
for all cv-unqualified extended floating-point types ([[basic.fundamental]](basic.fundamental "6.9.2Fundamental types"))[.](#ostream.general-1.sentence-1)
[🔗](#lib:basic_ostream)
namespace std {template<class charT, class traits = char_traits<charT>>class basic_ostream : virtual public basic_ios<charT, traits> {public:// types (inherited from [basic_ios](ios "31.5.4Class template basic_­ios[ios]"))using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; // [[ostream.cons]](#ostream.cons "31.7.6.2.2Constructors"), constructor/destructorexplicit basic_ostream(basic_streambuf<char_type, traits>* sb); virtual ~basic_ostream(); // [[ostream.sentry]](#ostream.sentry "31.7.6.2.4Class basic_­ostream::sentry"), prefix/suffixclass sentry; // [[ostream.formatted]](#ostream.formatted "31.7.6.3Formatted output functions"), formatted output basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
basic_ostream& operator<<(bool n);
basic_ostream& operator<<(short n);
basic_ostream& operator<<(unsigned short n);
basic_ostream& operator<<(int n);
basic_ostream& operator<<(unsigned int n);
basic_ostream& operator<<(long n);
basic_ostream& operator<<(unsigned long n);
basic_ostream& operator<<(long long n);
basic_ostream& operator<<(unsigned long long n);
basic_ostream& operator<<(float f);
basic_ostream& operator<<(double f);
basic_ostream& operator<<(long double f);
basic_ostream& operator<<(*extended-floating-point-type* f);
basic_ostream& operator<<(const void* p);
basic_ostream& operator<<(const volatile void* p);
basic_ostream& operator<<(nullptr_t);
basic_ostream& operator<<(basic_streambuf<char_type, traits>* sb); // [[ostream.unformatted]](#ostream.unformatted "31.7.6.4Unformatted output functions"), unformatted output basic_ostream& put(char_type c);
basic_ostream& write(const char_type* s, streamsize n);
basic_ostream& flush(); // [[ostream.seeks]](#ostream.seeks "31.7.6.2.5Seek members"), seeks pos_type tellp();
basic_ostream& seekp(pos_type);
basic_ostream& seekp(off_type, ios_base::seekdir); protected:// [[ostream.cons]](#ostream.cons "31.7.6.2.2Constructors"), copy/move constructor basic_ostream(const basic_ostream&) = delete;
basic_ostream(basic_ostream&& rhs); // [[ostream.assign]](#ostream.assign "31.7.6.2.3Assignment and swap"), assignment and swap basic_ostream& operator=(const basic_ostream&) = delete;
basic_ostream& operator=(basic_ostream&& rhs); void swap(basic_ostream& rhs); }; // [[ostream.inserters.character]](#ostream.inserters.character "31.7.6.3.4Character inserter function templates"), character inserterstemplate<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, charT); template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*); template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*); template<class traits> basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*); template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; template<class traits> basic_ostream<char, traits>&operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; template<class traits> basic_ostream<wchar_t, traits>&operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete;}
[2](#ostream.general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6060)
The class templatebasic_ostream defines a number of member function
signatures that assist in formatting and writing output to output sequences
controlled by a stream buffer[.](#ostream.general-2.sentence-1)
[3](#ostream.general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6067)
Two groups of member function signatures share common properties:
the[*formatted output functions*](#def:formatted_output_functions) (or[*inserters*](#def:inserters))
and the[*unformatted output functions.*](#def:unformatted_output_functions.) Both groups of output functions generate (or[*insert*](#def:insert))
output[*characters*](#def:characters) by actions equivalent to callingrdbuf()->sputc(int_type)[.](#ostream.general-3.sentence-1)
They may use other public members ofbasic_ostream except that they shall not invoke any virtual members ofrdbuf() exceptoverflow(),xsputn(),
andsync()[.](#ostream.general-3.sentence-2)
[4](#ostream.general-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6091)
If one of these called functions throws an exception, then unless explicitly noted otherwise
the output function setsbadbit in the error state[.](#ostream.general-4.sentence-1)
Ifbadbit is set inexceptions(),
the output function
rethrows the exception without completing its actions, otherwise
it does not throw anything and proceeds as if the called function had returned
a failure indication[.](#ostream.general-4.sentence-2)
[5](#ostream.general-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6105)
[*Note [1](#ostream.general-note-1)*:
The deleted overloads of operator<< prevent formatting characters as integers and strings as pointers[.](#ostream.general-5.sentence-1)
— *end note*]
#### [31.7.6.2.2](#ostream.cons) Constructors [[ostream.cons]](ostream.cons)
[🔗](#lib:basic_ostream,constructor)
`explicit basic_ostream(basic_streambuf<charT, traits>* sb);
`
[1](#ostream.cons-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6120)
*Effects*: Initializes the base class subobject withbasic_ios<charT, traits>::init(sb) ([[basic.ios.cons]](basic.ios.cons "31.5.4.2Constructors"))[.](#ostream.cons-1.sentence-1)
[2](#ostream.cons-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6125)
*Postconditions*: rdbuf() == sb[.](#ostream.cons-2.sentence-1)
[🔗](#lib:basic_ostream,constructor_)
`basic_ostream(basic_ostream&& rhs);
`
[3](#ostream.cons-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6136)
*Effects*: Move constructs from the rvalue rhs[.](#ostream.cons-3.sentence-1)
This is accomplished by default constructing the base class and callingbasic_ios<charT, traits>::move(rhs) to initialize the
base class[.](#ostream.cons-3.sentence-2)
[🔗](#lib:basic_ostream,destructor)
`virtual ~basic_ostream();
`
[4](#ostream.cons-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6150)
*Remarks*: Does not perform any operations onrdbuf()[.](#ostream.cons-4.sentence-1)
#### [31.7.6.2.3](#ostream.assign) Assignment and swap [[ostream.assign]](ostream.assign)
[🔗](#lib:operator=,basic_ostream)
`basic_ostream& operator=(basic_ostream&& rhs);
`
[1](#ostream.assign-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6164)
*Effects*: Equivalent to swap(rhs)[.](#ostream.assign-1.sentence-1)
[2](#ostream.assign-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6168)
*Returns*: *this[.](#ostream.assign-2.sentence-1)
[🔗](#lib:swap,basic_ostream)
`void swap(basic_ostream& rhs);
`
[3](#ostream.assign-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6179)
*Effects*: Calls basic_ios<charT, traits>::swap(rhs)[.](#ostream.assign-3.sentence-1)
#### [31.7.6.2.4](#ostream.sentry) Class basic_ostream::sentry [[ostream.sentry]](ostream.sentry)
[🔗](#lib:basic_ostream::sentry)
namespace std {template<class charT, class traits>class basic_ostream<charT, traits>::sentry {bool *ok_*; // *exposition only*public:explicit sentry(basic_ostream& os); ~sentry(); explicit operator bool() const { return *ok_*; } sentry(const sentry&) = delete;
sentry& operator=(const sentry&) = delete; };}
[1](#ostream.sentry-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6205)
The classsentry defines a class that is responsible for doing exception safe prefix and suffix
operations[.](#ostream.sentry-1.sentence-1)
[🔗](#lib:basic_ostream::sentry,constructor)
`explicit sentry(basic_ostream& os);
`
[2](#ostream.sentry-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6217)
Ifos.good() is nonzero, prepares for formatted or unformatted output[.](#ostream.sentry-2.sentence-1)
Ifos.tie() is not a null pointer, callsos.tie()->flush()[.](#ostream.sentry-2.sentence-2)[283](#footnote-283 "The call os.tie()->flush() does not necessarily occur if the function can determine that no synchronization is necessary.")
[3](#ostream.sentry-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6233)
If, after any preparation is completed,os.good() istrue,*ok_* == true otherwise,*ok_* == false[.](#ostream.sentry-3.sentence-1)
During preparation, the constructor may callsetstate(failbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#ostream.sentry-3.sentence-2)[284](#footnote-284 "The sentry constructor and destructor can also perform additional implementation-dependent operations.")
[🔗](#lib:basic_ostream::sentry,destructor)
`~sentry();
`
[4](#ostream.sentry-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6261)
If(os.flags() & ios_base::unitbuf) && !uncaught_exceptions()&& os.good() istrue,
callsos.rdbuf()->pubsync()[.](#ostream.sentry-4.sentence-1)
If that function returns −1 or
exits via an exception, sets badbit inos.rdstate() without propagating an exception[.](#ostream.sentry-4.sentence-2)
[🔗](#lib:operator_bool,basic_ostream::sentry)
`explicit operator bool() const;
`
[5](#ostream.sentry-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6279)
*Effects*: Returns*ok_*[.](#ostream.sentry-5.sentence-1)
[283)](#footnote-283)[283)](#footnoteref-283)
The callos.tie()->flush() does not necessarily occur if the function can determine that no
synchronization is necessary[.](#footnote-283.sentence-1)
[284)](#footnote-284)[284)](#footnoteref-284)
Thesentry constructor and destructor
can also perform additionalimplementation-dependent operations[.](#footnote-284.sentence-1)
#### [31.7.6.2.5](#ostream.seeks) Seek members [[ostream.seeks]](ostream.seeks)
[1](#ostream.seeks-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6287)
Each seek member function begins execution by constructing an object of class sentry[.](#ostream.seeks-1.sentence-1)
It returns by destroying the sentry object[.](#ostream.seeks-1.sentence-2)
[🔗](#lib:tellp,basic_ostream)
`pos_type tellp();
`
[2](#ostream.seeks-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6297)
*Returns*: Iffail() != false,
returnspos_type(-1) to indicate failure[.](#ostream.seeks-2.sentence-1)
Otherwise, returnsrdbuf()->pubseekoff(0, cur, out)[.](#ostream.seeks-2.sentence-2)
[🔗](#lib:seekp,basic_ostream)
`basic_ostream& seekp(pos_type pos);
`
[3](#ostream.seeks-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6314)
*Effects*: Iffail() != true,
executesrdbuf()->pubseekpos(pos, ios_base::out)[.](#ostream.seeks-3.sentence-1)
In case of failure, the function callssetstate(failbit) (which may throwios_base::failure)[.](#ostream.seeks-3.sentence-2)
[4](#ostream.seeks-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6325)
*Returns*: *this[.](#ostream.seeks-4.sentence-1)
[🔗](#lib:seekp,basic_ostream_)
`basic_ostream& seekp(off_type off, ios_base::seekdir dir);
`
[5](#ostream.seeks-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6336)
*Effects*: Iffail() != true,
executesrdbuf()->pubseekoff(off, dir, ios_base::out)[.](#ostream.seeks-5.sentence-1)
In case of failure, the function calls setstate(failbit) (which may throw ios_base::failure)[.](#ostream.seeks-5.sentence-2)
[6](#ostream.seeks-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6345)
*Returns*: *this[.](#ostream.seeks-6.sentence-1)
#### [31.7.6.3](#ostream.formatted) Formatted output functions [[ostream.formatted]](ostream.formatted)
#### [31.7.6.3.1](#ostream.formatted.reqmts) Common requirements [[ostream.formatted.reqmts]](ostream.formatted.reqmts)
[1](#ostream.formatted.reqmts-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6354)
Each formatted output function begins execution by constructing an object of classsentry[.](#ostream.formatted.reqmts-1.sentence-1)
If that object returnstrue when converted to a value of typebool,
the function endeavors
to generate the requested output[.](#ostream.formatted.reqmts-1.sentence-2)
If the generation fails, then the formatted output function doessetstate(ios_base::failbit),
which can throw an exception[.](#ostream.formatted.reqmts-1.sentence-3)
If an exception is thrown during output, thenios_base::badbit is set[285](#footnote-285 "This is done without causing an ios_­base::failure to be thrown.") in*this's
error state[.](#ostream.formatted.reqmts-1.sentence-4)
If(exceptions() & badbit) != 0 then the exception is rethrown[.](#ostream.formatted.reqmts-1.sentence-5)
Whether or not an exception is thrown, thesentry object is destroyed before leaving the formatted output function[.](#ostream.formatted.reqmts-1.sentence-6)
If no exception is thrown, the result of the formatted output function
is*this[.](#ostream.formatted.reqmts-1.sentence-7)
[2](#ostream.formatted.reqmts-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6387)
The descriptions of the individual formatted output functions
describe how they perform
output and do not mention thesentry object[.](#ostream.formatted.reqmts-2.sentence-1)
[3](#ostream.formatted.reqmts-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6394)
If a formatted output function of a stream os determines
padding, it does so as
follows[.](#ostream.formatted.reqmts-3.sentence-1)
Given a charT character sequence seq wherecharT is the character container type of the stream, if
the length of seq is less than os.width(), then enough copies ofos.fill() are added to this sequence as necessary to pad to a
width of os.width() characters[.](#ostream.formatted.reqmts-3.sentence-2)
If(os.flags() & ios_base::adjustfield) == ios_base::left istrue, the fill characters are placed
after the character sequence; otherwise, they are placed before the
character sequence[.](#ostream.formatted.reqmts-3.sentence-3)
[285)](#footnote-285)[285)](#footnoteref-285)
This is done without causing anios_base::failure to be thrown[.](#footnote-285.sentence-1)
#### [31.7.6.3.2](#ostream.inserters.arithmetic) Arithmetic inserters [[ostream.inserters.arithmetic]](ostream.inserters.arithmetic)
[🔗](#lib:operator%3c%3c,basic_ostream)
`basic_ostream& operator<<(bool val);
basic_ostream& operator<<(short val);
basic_ostream& operator<<(unsigned short val);
basic_ostream& operator<<(int val);
basic_ostream& operator<<(unsigned int val);
basic_ostream& operator<<(long val);
basic_ostream& operator<<(unsigned long val);
basic_ostream& operator<<(long long val);
basic_ostream& operator<<(unsigned long long val);
basic_ostream& operator<<(float val);
basic_ostream& operator<<(double val);
basic_ostream& operator<<(long double val);
basic_ostream& operator<<(const void* val);
`
[1](#ostream.inserters.arithmetic-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6427)
*Effects*: The classesnum_get<> andnum_put<> handle locale-dependent numeric formatting and
parsing[.](#ostream.inserters.arithmetic-1.sentence-1)
These inserter functions use the imbuedlocale value to perform numeric formatting[.](#ostream.inserters.arithmetic-1.sentence-2)
When val is of typebool,long,unsigned long,long long, unsigned long long,double,long double,
orconst void*,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), val).failed();
When val is of typeshort the formatting conversion occurs as if it performed the following code fragment:ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(),
baseflags == ios_base::oct || baseflags == ios_base::hex ? static_cast<long>(static_cast<unsigned short>(val)): static_cast<long>(val)).failed();
When val is of typeint the formatting conversion occurs as if it performed the following code fragment:ios_base::fmtflags baseflags = ios_base::flags() & ios_base::basefield;bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(),
baseflags == ios_base::oct || baseflags == ios_base::hex ? static_cast<long>(static_cast<unsigned int>(val)): static_cast<long>(val)).failed();
When val is of typeunsigned short orunsigned int the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<unsigned long>(val)).failed();
When val is of typefloat the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();
[2](#ostream.inserters.arithmetic-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6496)
The first argument provides an object of theostreambuf_iterator<> class which is an iterator for class basic_ostream<>[.](#ostream.inserters.arithmetic-2.sentence-1)
It bypassesostreams
and usesstreambufs
directly[.](#ostream.inserters.arithmetic-2.sentence-2)
Classlocale relies on these types as its
interface to iostreams, since for flexibility it has been abstracted
away from direct dependence onostream[.](#ostream.inserters.arithmetic-2.sentence-3)
The second parameter is a reference to the base class subobject of typeios_base[.](#ostream.inserters.arithmetic-2.sentence-4)
It provides formatting specifications such as field width, and
a locale from which to obtain other facets[.](#ostream.inserters.arithmetic-2.sentence-5)
Iffailed istrue then doessetstate(badbit),
which may throw an exception, and returns[.](#ostream.inserters.arithmetic-2.sentence-6)
[3](#ostream.inserters.arithmetic-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6523)
*Returns*: *this[.](#ostream.inserters.arithmetic-3.sentence-1)
[🔗](#lib:operator%3c%3c,basic_ostream_)
`basic_ostream& operator<<(const volatile void* p);
`
[4](#ostream.inserters.arithmetic-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6534)
*Effects*: Equivalent to: return operator<<(const_cast<const void*>(p));
[🔗](#ostream.inserters.arithmetic-itemdecl:3)
`basic_ostream& operator<<(extended-floating-point-type val);
`
[5](#ostream.inserters.arithmetic-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6544)
*Effects*: If the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<double>(val)).failed();
Otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of long double,
the formatting conversion occurs as if it performed the following code fragment:bool failed = use_facet<num_put<charT, ostreambuf_iterator<charT, traits>>>( getloc()).put(*this, *this, fill(), static_cast<long double>(val)).failed();
Otherwise, an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#ostream.inserters.arithmetic-5.sentence-3)
If failed is true then does setstate(badbit),
which may throw an exception, and returns[.](#ostream.inserters.arithmetic-5.sentence-4)
[6](#ostream.inserters.arithmetic-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6568)
*Returns*: *this[.](#ostream.inserters.arithmetic-6.sentence-1)
#### [31.7.6.3.3](#ostream.inserters) basic_ostream::operator<< [[ostream.inserters]](ostream.inserters)
[🔗](#lib:operator%3c%3c,basic_ostream__)
`basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
`
[1](#ostream.inserters-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6581)
*Effects*: None[.](#ostream.inserters-1.sentence-1)
Does not behave as a formatted output function (as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements"))[.](#ostream.inserters-1.sentence-2)
[2](#ostream.inserters-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6587)
*Returns*: pf(*this)[.](#ostream.inserters-2.sentence-1)[286](#footnote-286 "See, for example, the function signature endl(basic_­ostream&amp;) ([ostream.manip]).")
[🔗](#lib:operator%3c%3c,basic_ostream___)
`basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT, traits>&));
`
[3](#ostream.inserters-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6603)
*Effects*: Callspf(*this)[.](#ostream.inserters-3.sentence-1)
This inserter does not
behave as a formatted output function (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements"))[.](#ostream.inserters-3.sentence-2)
[4](#ostream.inserters-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6610)
*Returns*: *this[.](#ostream.inserters-4.sentence-1)[287](#footnote-287 "See, for example, the function signature dec(ios_­base&amp;) ([basefield.manip]).")
[🔗](#lib:operator%3c%3c,basic_ostream____)
`basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
`
[5](#ostream.inserters-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6626)
*Effects*: Callspf(*this)[.](#ostream.inserters-5.sentence-1)
This inserter does not
behave as a formatted output function (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements"))[.](#ostream.inserters-5.sentence-2)
[6](#ostream.inserters-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6633)
*Returns*: *this[.](#ostream.inserters-6.sentence-1)
[🔗](#lib:operator%3c%3c,basic_ostream_____)
`basic_ostream& operator<<(basic_streambuf<charT, traits>* sb);
`
[7](#ostream.inserters-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6644)
*Effects*: Behaves as an unformatted output function ([[ostream.unformatted]](#ostream.unformatted "31.7.6.4Unformatted output functions"))[.](#ostream.inserters-7.sentence-1)
After the sentry object is
constructed, ifsb is null callssetstate(badbit) (which may throwios_base::failure)[.](#ostream.inserters-7.sentence-2)
[8](#ostream.inserters-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6654)
Gets characters from sb and inserts them in*this[.](#ostream.inserters-8.sentence-1)
Characters are read from sb and inserted until any of the following occurs:
- [(8.1)](#ostream.inserters-8.1)
end-of-file occurs on the input sequence;
- [(8.2)](#ostream.inserters-8.2)
inserting in the output sequence fails
(in which case the character to be inserted is not extracted);
- [(8.3)](#ostream.inserters-8.3)
an exception occurs while getting a character from sb[.](#ostream.inserters-8.sentence-2)
[9](#ostream.inserters-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6670)
If the function inserts no characters, it callssetstate(failbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#ostream.inserters-9.sentence-1)
If an exception was thrown while extracting a character,
the function setsfailbit in the error state, and iffailbit is set inexceptions() the caught exception is rethrown[.](#ostream.inserters-9.sentence-2)
[10](#ostream.inserters-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6684)
*Returns*: *this[.](#ostream.inserters-10.sentence-1)
[🔗](#lib:operator%3c%3c,basic_ostream______)
`basic_ostream& operator<<(nullptr_t);
`
[11](#ostream.inserters-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6695)
*Effects*: Equivalent to:return *this << s; where s is animplementation-defined[NTCTS](defns.ntcts "3.36NTCTS[defns.ntcts]")[.](#ostream.inserters-11.sentence-1)
[286)](#footnote-286)[286)](#footnoteref-286)
See, for example, the function signatureendl(basic_ostream&) ([[ostream.manip]](#ostream.manip "31.7.6.5Standard basic_­ostream manipulators"))[.](#footnote-286.sentence-1)
[287)](#footnote-287)[287)](#footnoteref-287)
See, for example, the function signaturedec(ios_base&) ([[basefield.manip]](basefield.manip "31.5.5.3basefield manipulators"))[.](#footnote-287.sentence-1)
#### [31.7.6.3.4](#ostream.inserters.character) Character inserter function templates [[ostream.inserters.character]](ostream.inserters.character)
[🔗](#lib:operator%3c%3c,basic_ostream_______)
`template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, charT c);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, char c);
// specialization
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, char c);
// signed and unsigned
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, signed char c);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
`
[1](#ostream.inserters.character-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6725)
*Effects*: Behaves as a [formatted output function](#ostream.formatted.reqmts "31.7.6.3.1Common requirements[ostream.formatted.reqmts]") of out[.](#ostream.inserters.character-1.sentence-1)
Constructs a character sequence seq[.](#ostream.inserters.character-1.sentence-2)
If c has typechar and the character container type of the stream is notchar,
then seq consists ofout.widen(c);
otherwise seq consists ofc[.](#ostream.inserters.character-1.sentence-3)
Determines padding for seq as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements")[.](#ostream.inserters.character-1.sentence-4)
Inserts seq intoout[.](#ostream.inserters.character-1.sentence-5)
Calls os.width(0)[.](#ostream.inserters.character-1.sentence-6)
[2](#ostream.inserters.character-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6740)
*Returns*: out[.](#ostream.inserters.character-2.sentence-1)
[🔗](#lib:operator%3c%3c,basic_ostream________)
`template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const charT* s);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, const char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const signed char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out,
const unsigned char* s);
`
[3](#ostream.inserters.character-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6761)
*Preconditions*: s is not a null pointer[.](#ostream.inserters.character-3.sentence-1)
[4](#ostream.inserters.character-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6765)
*Effects*: Behaves like a formatted inserter (as described in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements")) of out[.](#ostream.inserters.character-4.sentence-1)
Creates a character sequence seq of n characters
starting at s, each widened usingout.widen() ([[basic.ios.members]](basic.ios.members "31.5.4.3Member functions")),
where n is the number that would be computed as if by:
- [(4.1)](#ostream.inserters.character-4.1)
traits::length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst charT*,
and also for the overload where the first argument is of typebasic_ostream<char, traits>& and the second is of typeconst char*,
- [(4.2)](#ostream.inserters.character-4.2)
char_traits<char>::length(s) for the overload where the first argument is of typebasic_ostream<charT, traits>& and the second is of typeconst char*,
- [(4.3)](#ostream.inserters.character-4.3)
traits::length(reinterpret_cast<const char*>(s)) for the other two overloads[.](#ostream.inserters.character-4.sentence-2)
Determines padding for seq as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements")[.](#ostream.inserters.character-4.sentence-3)
Inserts seq intoout[.](#ostream.inserters.character-4.sentence-4)
Calls width(0)[.](#ostream.inserters.character-4.sentence-5)
[5](#ostream.inserters.character-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6797)
*Returns*: out[.](#ostream.inserters.character-5.sentence-1)
#### [31.7.6.3.5](#ostream.formatted.print) Print [[ostream.formatted.print]](ostream.formatted.print)
[🔗](#lib:print)
`template<class... Args>
void print(ostream& os, format_string<Args...> fmt, Args&&... args);
`
[1](#ostream.formatted.print-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6811)
*Effects*: If the ordinary literal encoding ([[lex.charset]](lex.charset "5.3.1Character sets")) is UTF-8, equivalent to:vprint_unicode(os, fmt.*str*, make_format_args(args...));
Otherwise, equivalent to:vprint_nonunicode(os, fmt.*str*, make_format_args(args...));
[🔗](#lib:println)
`template<class... Args>
void println(ostream& os, format_string<Args...> fmt, Args&&... args);
`
[2](#ostream.formatted.print-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6830)
*Effects*: Equivalent to:print(os, "{}\n", format(os.getloc(), fmt, std::forward<Args>(args)...));
[🔗](#lib:println_)
`void println(ostream& os);
`
[3](#ostream.formatted.print-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6844)
*Effects*: Equivalent to:print(os, "\n");
[🔗](#lib:vprint_unicode)
`void vprint_unicode(ostream& os, string_view fmt, format_args args);
void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
`
[4](#ostream.formatted.print-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6860)
*Effects*: Behaves as a formatted output function ([[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements"))
of os, except that:
- [(4.1)](#ostream.formatted.print-4.1)
failure to generate output is reported as specified below, and
- [(4.2)](#ostream.formatted.print-4.2)
any exception thrown by the call to vformat is propagated
without regard to the value of os.exceptions() and
without turning on ios_base::badbit in the error state of os[.](#ostream.formatted.print-4.sentence-1)
After constructing a sentry object,
the function initializes a variable with automatic storage duration viastring out = vformat(os.getloc(), fmt, args);
- [(4.3)](#ostream.formatted.print-4.3)
If the function is vprint_unicode andos is a stream that refers to a terminal that
is capable of displaying Unicode only via a native Unicode API,
which is determined in an implementation-defined manner,
flushes os and then
writes out to the terminal using the native Unicode API;
if out contains invalid code units,the behavior is undefined[.](#ostream.formatted.print-4.3.sentence-1)
Then establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2Abstract machine"))[.](#ostream.formatted.print-4.3.sentence-2)
- [(4.4)](#ostream.formatted.print-4.4)
Otherwise
inserts the character sequence
[out.begin(), out.end()) into os[.](#ostream.formatted.print-4.4.sentence-1)
If writing to the terminal or inserting into os fails,
calls os.setstate(ios_base::badbit) (which may throw ios_base::failure)[.](#ostream.formatted.print-4.sentence-3)
[5](#ostream.formatted.print-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6902)
*Recommended practice*: For vprint_unicode,
if invoking the native Unicode API requires transcoding,
implementations should substitute invalid code units
with U+fffd replacement character per
the Unicode Standard, Chapter 3.9 U+fffd Substitution in Conversion[.](#ostream.formatted.print-5.sentence-1)
#### [31.7.6.4](#ostream.unformatted) Unformatted output functions [[ostream.unformatted]](ostream.unformatted)
[1](#ostream.unformatted-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6913)
Each
unformatted
output function begins execution by constructing an object of classsentry[.](#ostream.unformatted-1.sentence-1)
If that object returnstrue,
while converting to a value of typebool,
the function endeavors
to generate the requested output[.](#ostream.unformatted-1.sentence-2)
If an exception is thrown during output, thenios_base::badbit is set[288](#footnote-288 "This is done without causing an ios_­base::failure to be thrown.") in*this's
error state[.](#ostream.unformatted-1.sentence-3)
If(exceptions() & badbit) != 0 then the exception is rethrown[.](#ostream.unformatted-1.sentence-4)
In any case, the unformatted output function ends by destroying thesentry object, then, if no exception was thrown, returning the value
specified for the unformatted output function[.](#ostream.unformatted-1.sentence-5)
[🔗](#lib:put,basic_ostream)
`basic_ostream& put(char_type c);
`
[2](#ostream.unformatted-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6948)
*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-2.sentence-1)
After constructing a sentry object, inserts
the character c, if possible[.](#ostream.unformatted-2.sentence-2)[289](#footnote-289 "Note that this function is not overloaded on types signed char and unsigned char.")
[3](#ostream.unformatted-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6961)
Otherwise, callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#ostream.unformatted-3.sentence-1)
[4](#ostream.unformatted-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6967)
*Returns*: *this[.](#ostream.unformatted-4.sentence-1)
[🔗](#lib:write,basic_ostream)
`basic_ostream& write(const char_type* s, streamsize n);
`
[5](#ostream.unformatted-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L6978)
*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-5.sentence-1)
After constructing a sentry object, obtains
characters to insert from
successive locations of an array whose first element is designated bys[.](#ostream.unformatted-5.sentence-2)[290](#footnote-290 "Note that this function is not overloaded on types signed char and unsigned char.")
Characters are inserted until either of the following occurs:
- [(5.1)](#ostream.unformatted-5.1)
n characters are inserted;
- [(5.2)](#ostream.unformatted-5.2)
inserting in the output sequence fails
(in which case the function callssetstate(badbit),
which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#ostream.unformatted-5.sentence-3)
[6](#ostream.unformatted-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7003)
*Returns*: *this[.](#ostream.unformatted-6.sentence-1)
[🔗](#lib:flush,basic_ostream)
`basic_ostream& flush();
`
[7](#ostream.unformatted-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7014)
*Effects*: Behaves as an unformatted output function (as described above)[.](#ostream.unformatted-7.sentence-1)
Ifrdbuf() is not a null pointer,
constructs a sentry object[.](#ostream.unformatted-7.sentence-2)
If that object returns true when converted to a value of type bool the function
callsrdbuf()->pubsync()[.](#ostream.unformatted-7.sentence-3)
If that function returns −1 callssetstate(badbit) (which may throwios_base::failure ([[iostate.flags]](iostate.flags "31.5.4.4Flags functions")))[.](#ostream.unformatted-7.sentence-4)
Otherwise, if the sentry object returns false, does nothing[.](#ostream.unformatted-7.sentence-5)
[8](#ostream.unformatted-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7030)
*Returns*: *this[.](#ostream.unformatted-8.sentence-1)
[288)](#footnote-288)[288)](#footnoteref-288)
This is done without causing anios_base::failure to be thrown[.](#footnote-288.sentence-1)
[289)](#footnote-289)[289)](#footnoteref-289)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-289.sentence-1)
[290)](#footnote-290)[290)](#footnoteref-290)
Note that this function is not overloaded on typessigned char andunsigned char[.](#footnote-290.sentence-1)
#### [31.7.6.5](#ostream.manip) Standard basic_ostream manipulators [[ostream.manip]](ostream.manip)
[1](#ostream.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7037)
Each instantiation of any of the function templates
specified in this subclause
is a designated addressable function ([[namespace.std]](namespace.std "16.4.5.2.1Namespace std"))[.](#ostream.manip-1.sentence-1)
[🔗](#lib:endl_)
`template<class charT, class traits>
basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);
`
[2](#ostream.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7049)
*Effects*: Callsos.put(os.widen('\n')),
thenos.flush()[.](#ostream.manip-2.sentence-1)
[3](#ostream.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7056)
*Returns*: os[.](#ostream.manip-3.sentence-1)
[🔗](#lib:ends)
`template<class charT, class traits>
basic_ostream<charT, traits>& ends(basic_ostream<charT, traits>& os);
`
[4](#ostream.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7068)
*Effects*: Inserts a null character into the output sequence:
callsos.put(charT())[.](#ostream.manip-4.sentence-1)
[5](#ostream.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7074)
*Returns*: os[.](#ostream.manip-5.sentence-1)
[🔗](#lib:flush__)
`template<class charT, class traits>
basic_ostream<charT, traits>& flush(basic_ostream<charT, traits>& os);
`
[6](#ostream.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7086)
*Effects*: Callsos.flush()[.](#ostream.manip-6.sentence-1)
[7](#ostream.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7091)
*Returns*: os[.](#ostream.manip-7.sentence-1)
[🔗](#lib:emit_on_flush)
`template<class charT, class traits>
basic_ostream<charT, traits>& emit_on_flush(basic_ostream<charT, traits>& os);
`
[8](#ostream.manip-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7103)
*Effects*: If os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
calls buf->set_emit_on_sync(true)[.](#ostream.manip-8.sentence-1)
Otherwise this manipulator has no effect[.](#ostream.manip-8.sentence-2)
[*Note [1](#ostream.manip-note-1)*:
To work around the issue that theAllocator template argument cannot be deduced,
implementations can introduce an intermediate base class
to basic_syncbuf that manages its *emit-on-sync* flag[.](#ostream.manip-8.sentence-3)
— *end note*]
[9](#ostream.manip-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7117)
*Returns*: os[.](#ostream.manip-9.sentence-1)
[🔗](#lib:noemit_on_flush)
`template<class charT, class traits>
basic_ostream<charT, traits>& noemit_on_flush(basic_ostream<charT, traits>& os);
`
[10](#ostream.manip-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7129)
*Effects*: If os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
calls buf->set_emit_on_sync(false)[.](#ostream.manip-10.sentence-1)
Otherwise this manipulator has no effect[.](#ostream.manip-10.sentence-2)
[11](#ostream.manip-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7137)
*Returns*: os[.](#ostream.manip-11.sentence-1)
[🔗](#lib:flush_emit)
`template<class charT, class traits>
basic_ostream<charT, traits>& flush_emit(basic_ostream<charT, traits>& os);
`
[12](#ostream.manip-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7149)
*Effects*: Calls os.flush()[.](#ostream.manip-12.sentence-1)
Then, if os.rdbuf() is abasic_syncbuf<charT, traits, Allocator>*,
called buf for the purpose of exposition,
behaves as an unformatted output function ([[ostream.unformatted]](#ostream.unformatted "31.7.6.4Unformatted output functions"))
of os[.](#ostream.manip-12.sentence-2)
After constructing a sentry object, calls buf->emit()[.](#ostream.manip-12.sentence-3)
If that call returns false, calls os.setstate(ios_base::badbit)[.](#ostream.manip-12.sentence-4)
[13](#ostream.manip-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7160)
*Returns*: os[.](#ostream.manip-13.sentence-1)
#### [31.7.6.6](#ostream.rvalue) Rvalue stream insertion [[ostream.rvalue]](ostream.rvalue)
[🔗](#lib:operator%3c%3c,basic_ostream_________)
`template<class Ostream, class T>
Ostream&& operator<<(Ostream&& os, const T& x);
`
[1](#ostream.rvalue-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7174)
*Constraints*: The expression os << x is well-formed
when treated as an unevaluated operand andOstream is publicly and unambiguously derived from ios_base[.](#ostream.rvalue-1.sentence-1)
[2](#ostream.rvalue-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7180)
*Effects*: As if by: os << x;
[3](#ostream.rvalue-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7184)
*Returns*: std::move(os)[.](#ostream.rvalue-3.sentence-1)
### [31.7.7](#std.manip) Standard manipulators [[std.manip]](std.manip)
[1](#std.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7192)
The header [<iomanip>](#header:%3ciomanip%3e "31.7.3Header <iomanip> synopsis[iomanip.syn]") defines several functions that support
extractors and inserters that alter information maintained by classios_base and its derived classes[.](#std.manip-1.sentence-1)
[🔗](#lib:resetiosflags)
`unspecified resetiosflags(ios_base::fmtflags mask);
`
[2](#std.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7203)
*Returns*: An object of
unspecified type such that if out is an object of typebasic_ostream<charT, traits> then the expressionout << resetiosflags(mask) behaves as if it calledf(out, mask), or if in is an object of typebasic_istream<charT, traits> then the expressionin >> resetiosflags(mask) behaves as if it calledf(in, mask), where the function f is defined as:[291](#footnote-291 "The expression cin >> resetiosflags(ios_­base::skipws) clears ios_­base::skipws in the format flags stored in the basic_­istream<charT, traits> object cin (the same as cin >> noskipws), and the expression cout &lt;&lt; resetiosflags(ios_­base::showbase) clears ios_­base::showbase in the format flags stored in the basic_­ostream<charT, traits> object cout (the same as cout &lt;&lt; noshowbase).")void f(ios_base& str, ios_base::fmtflags mask) {// reset specified flags str.setf(ios_base::fmtflags(0), mask);}
The expression out << resetiosflags(mask) has
type basic_ostream<charT, traits>& and value out[.](#std.manip-2.sentence-2)
The
expression in >> resetiosflags(mask) has typebasic_istream<charT, traits>& and value in[.](#std.manip-2.sentence-3)
[🔗](#lib:setiosflags)
`unspecified setiosflags(ios_base::fmtflags mask);
`
[3](#std.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7242)
*Returns*: An object of unspecified type such that ifout is an object of typebasic_ostream<charT, traits> then the expressionout << setiosflags(mask) behaves as if it calledf(out, mask),
or ifin is an object of typebasic_istream<charT, traits> then the expressionin >> setiosflags(mask) behaves as if it calledf(in, mask), where the function f is defined as:
[🔗](#lib:fmtflags,ios_base)
void f(ios_base& str, ios_base::fmtflags mask) {// set specified flags str.setf(mask);}
The expressionout << setiosflags(mask) has typebasic_ostream<charT, traits>& and valueout[.](#std.manip-3.sentence-2)
The expressionin >> setiosflags(mask) has typebasic_istream<charT, traits>& and valuein[.](#std.manip-3.sentence-3)
[🔗](#lib:setbase)
`unspecified setbase(int base);
`
[4](#std.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7288)
*Returns*: An object of unspecified type such that ifout is an object of typebasic_ostream<charT, traits> then the expressionout << setbase(base) behaves as if it calledf(out, base),
or ifin is an object of typebasic_istream<charT, traits> then the expressionin >> setbase(base) behaves as if it calledf(in, base), where the function f is defined as:void f(ios_base& str, int base) {// set basefield str.setf(base == 8 ? ios_base::oct : base == 10 ? ios_base::dec : base == 16 ? ios_base::hex : ios_base::fmtflags(0), ios_base::basefield);}
The expressionout << setbase(base) has typebasic_ostream<charT, traits>& and valueout[.](#std.manip-4.sentence-2)
The expressionin >> setbase(base) has typebasic_istream<charT, traits>& and valuein[.](#std.manip-4.sentence-3)
[🔗](#lib:setfill)
`unspecified setfill(char_type c);
`
[5](#std.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7336)
*Returns*: An object of unspecified type such that ifout is an object of typebasic_ostream<charT, traits> and c has typecharT then the expressionout << setfill(c) behaves as if it calledf(out, c), where the function f is defined as:template<class charT, class traits>void f(basic_ios<charT, traits>& str, charT c) {// set fill character str.fill(c);}
The expressionout << setfill(c) has typebasic_ostream<charT, traits>& and valueout[.](#std.manip-5.sentence-2)
[🔗](#lib:setprecision)
`unspecified setprecision(int n);
`
[6](#std.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7370)
*Returns*: An object of unspecified type such that ifout is an object of typebasic_ostream<charT, traits> then the expressionout << setprecision(n) behaves as if it calledf(out, n),
or ifin is an object of typebasic_istream<charT, traits> then the expressionin >> setprecision(n) behaves as if it calledf(in, n), where the function f is defined as:void f(ios_base& str, int n) {// set precision str.precision(n);}
The expressionout << setprecision(n) has typebasic_ostream<charT, traits>& and valueout[.](#std.manip-6.sentence-2)
The expressionin >> setprecision(n) has typebasic_istream<charT, traits>& and valuein[.](#std.manip-6.sentence-3)
[🔗](#lib:setw)
`unspecified setw(int n);
`
[7](#std.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7415)
*Returns*: An object of unspecified type such that ifout is an instance ofbasic_ostream<charT, traits> then the expressionout << setw(n) behaves as if it calledf(out, n),
or ifin is an object of typebasic_istream<charT, traits> then the expressionin >> setw(n) behaves as if it calledf(in, n), where the function f is defined as:void f(ios_base& str, int n) {// set width str.width(n);}
The expressionout << setw(n) has typebasic_ostream<charT, traits>& and valueout[.](#std.manip-7.sentence-2)
The expressionin >> setw(n) has typebasic_istream<charT, traits>& and valuein[.](#std.manip-7.sentence-3)
[291)](#footnote-291)[291)](#footnoteref-291)
The expression cin >> resetiosflags(ios_base::skipws) clears ios_base::skipws in the format flags stored in thebasic_istream<charT, traits> object cin (the same ascin >> noskipws), and the expressioncout << resetiosflags(ios_base::showbase) clears ios_base::showbase in the
format flags stored in the basic_ostream<charT, traits> objectcout (the same as cout << noshowbase)[.](#footnote-291.sentence-1)
### [31.7.8](#ext.manip) Extended manipulators [[ext.manip]](ext.manip)
[1](#ext.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7456)
The header [<iomanip>](#header:%3ciomanip%3e "31.7.3Header <iomanip> synopsis[iomanip.syn]") defines several functions that support extractors and inserters that allow for the
parsing and formatting of sequences and values for money and time[.](#ext.manip-1.sentence-1)
[🔗](#lib:get_money)
`template<class moneyT> unspecified get_money(moneyT& mon, bool intl = false);
`
[2](#ext.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7466)
*Mandates*: The type moneyT is either long double or
a specialization of the basic_string template ([[strings]](strings "27Strings library"))[.](#ext.manip-2.sentence-1)
[3](#ext.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7471)
*Effects*: The expression in >> get_money(mon, intl) described below
behaves as a [formatted input function](#istream.formatted.reqmts "31.7.5.3.1Common requirements[istream.formatted.reqmts]")[.](#ext.manip-3.sentence-1)
[4](#ext.manip-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7476)
*Returns*: An object of unspecified type such that ifin is an object of type basic_istream<charT, traits> then the expression in >> get_money(mon, intl) behaves as if it calledf(in, mon, intl), where the function f is defined as:template<class charT, class traits, class moneyT>void f(basic_ios<charT, traits>& str, moneyT& mon, bool intl) {using Iter = istreambuf_iterator<charT, traits>; using MoneyGet = money_get<charT, Iter>;
ios_base::iostate err = ios_base::goodbit; const MoneyGet& mg = use_facet<MoneyGet>(str.getloc());
mg.get(Iter(str.rdbuf()), Iter(), intl, str, err, mon); if (ios_base::goodbit != err) str.setstate(err);}
The expression in >> get_money(mon, intl) has typebasic_istream<charT, traits>& and value in[.](#ext.manip-4.sentence-2)
[🔗](#lib:put_money)
`template<class moneyT> unspecified put_money(const moneyT& mon, bool intl = false);
`
[5](#ext.manip-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7508)
*Mandates*: The type moneyT is either long double or
a specialization of the basic_string template ([[strings]](strings "27Strings library"))[.](#ext.manip-5.sentence-1)
[6](#ext.manip-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7513)
*Returns*: An object of unspecified type such that ifout is an object of type basic_ostream<charT, traits> then the expression out << put_money(mon, intl) behaves as a[formatted output function](#ostream.formatted.reqmts "31.7.6.3.1Common requirements[ostream.formatted.reqmts]") that callsf(out, mon, intl), where the function f is defined as:template<class charT, class traits, class moneyT>void f(basic_ios<charT, traits>& str, const moneyT& mon, bool intl) {using Iter = ostreambuf_iterator<charT, traits>; using MoneyPut = money_put<charT, Iter>; const MoneyPut& mp = use_facet<MoneyPut>(str.getloc()); const Iter end = mp.put(Iter(str.rdbuf()), intl, str, str.fill(), mon); if (end.failed()) str.setstate(ios_base::badbit);}
The expression out << put_money(mon, intl) has typebasic_ostream<charT, traits>& and value out[.](#ext.manip-6.sentence-2)
[🔗](#lib:get_time)
`template<class charT> unspecified get_time(tm* tmb, const charT* fmt);
`
[7](#ext.manip-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7544)
*Preconditions*: The argument tmb is a valid pointer to an object of type tm,
and [fmt, fmt + char_traits<charT>::length(fmt)) is a valid range[.](#ext.manip-7.sentence-1)
[8](#ext.manip-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7549)
*Returns*: An object of unspecified type such that if in is an object of typebasic_istream<charT, traits> then the expression in >> get_time(tmb,
fmt) behaves as if it called f(in, tmb, fmt), where the function f is
defined as:template<class charT, class traits>void f(basic_ios<charT, traits>& str, tm* tmb, const charT* fmt) {using Iter = istreambuf_iterator<charT, traits>; using TimeGet = time_get<charT, Iter>;
ios_base::iostate err = ios_base::goodbit; const TimeGet& tg = use_facet<TimeGet>(str.getloc());
tg.get(Iter(str.rdbuf()), Iter(), str, err, tmb,
fmt, fmt + traits::length(fmt)); if (err != ios_base::goodbit) str.setstate(err);}
The expression in >> get_time(tmb, fmt) has typebasic_istream<charT, traits>& and value in[.](#ext.manip-8.sentence-2)
[🔗](#lib:put_time)
`template<class charT> unspecified put_time(const tm* tmb, const charT* fmt);
`
[9](#ext.manip-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7582)
*Preconditions*: The argument tmb is a valid pointer to an object of type tm,
and [fmt, fmt + char_traits<charT>::length(fmt)) is a valid range[.](#ext.manip-9.sentence-1)
[10](#ext.manip-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7587)
*Returns*: An object of unspecified type such that if out is an object of
type basic_ostream<charT, traits> then the expressionout << put_time(tmb, fmt) behaves as if it called f(out, tmb, fmt),
where the function f is defined as:template<class charT, class traits>void f(basic_ios<charT, traits>& str, const tm* tmb, const charT* fmt) {using Iter = ostreambuf_iterator<charT, traits>; using TimePut = time_put<charT, Iter>; const TimePut& tp = use_facet<TimePut>(str.getloc()); const Iter end = tp.put(Iter(str.rdbuf()), str, str.fill(), tmb,
fmt, fmt + traits::length(fmt)); if (end.failed()) str.setstate(ios_base::badbit);}
The expression out << put_time(tmb, fmt) has typebasic_ostream<charT, traits>& and value out[.](#ext.manip-10.sentence-2)
### [31.7.9](#quoted.manip) Quoted manipulators [[quoted.manip]](quoted.manip)
[1](#quoted.manip-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7614)
[*Note [1](#quoted.manip-note-1)*:
Quoted manipulators provide string insertion and extraction of quoted strings (for example, XML and CSV formats)[.](#quoted.manip-1.sentence-1)
Quoted manipulators are useful in ensuring that the content of a string with embedded spaces remains unchanged if inserted and then extracted via stream I/O[.](#quoted.manip-1.sentence-2)
— *end note*]
[🔗](#lib:quoted)
`template<class charT>
unspecified quoted(const charT* s, charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits, class Allocator>
unspecified quoted(const basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
template<class charT, class traits>
unspecified quoted(basic_string_view<charT, traits> s,
charT delim = charT('"'), charT escape = charT('\\'));
`
[2](#quoted.manip-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7632)
*Returns*: An object of unspecified type such that if out is an instance
of basic_ostream with member type char_type the same ascharT and with member type traits_type, which in the second and third
forms is the same as traits, then the expressionout << quoted(s, delim, escape) behaves as a [formatted output function](#ostream.formatted.reqmts "31.7.6.3.1Common requirements[ostream.formatted.reqmts]") of out[.](#quoted.manip-2.sentence-1)
This forms a character sequence seq, initially
consisting of the following elements:
- [(2.1)](#quoted.manip-2.1)
delim[.](#quoted.manip-2.1.sentence-1)
- [(2.2)](#quoted.manip-2.2)
Each character in s[.](#quoted.manip-2.2.sentence-1)
If the character to be output is equal toescape or delim, as determined by traits_type::eq, first
output escape[.](#quoted.manip-2.2.sentence-2)
- [(2.3)](#quoted.manip-2.3)
delim[.](#quoted.manip-2.3.sentence-1)
Let x be the number of elements initially in seq[.](#quoted.manip-2.sentence-3)
Then padding is determined for seq as described
in [[ostream.formatted.reqmts]](#ostream.formatted.reqmts "31.7.6.3.1Common requirements"), seq is inserted as if by callingout.rdbuf()->sputn(seq, n), where n is the larger ofout.width() and x, and out.width(0) is called[.](#quoted.manip-2.sentence-4)
The expression out << quoted(s, delim, escape) has typebasic_ostream<charT, traits>& and value out[.](#quoted.manip-2.sentence-5)
[🔗](#lib:quoted_)
`template<class charT, class traits, class Allocator>
unspecified quoted(basic_string<charT, traits, Allocator>& s,
charT delim = charT('"'), charT escape = charT('\\'));
`
[3](#quoted.manip-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7666)
*Returns*: An object of unspecified type such that:
- [(3.1)](#quoted.manip-3.1)
If in is an instance of basic_istream with member typeschar_type and traits_type the same as charT and traits, respectively, then the expressionin >> quoted(s, delim, escape) behaves as if it extracts the following
characters from in usingoperator>>(basic_istream<charT, traits>&, charT&) ([[istream.extractors]](#istream.extractors "31.7.5.3.3basic_­istream::operator>>"))
which may throw ios_base::failure ([[ios.failure]](ios.failure "31.5.2.2.1Class ios_­base::failure")):
* [(3.1.1)](#quoted.manip-3.1.1)
If the first character extracted is equal to delim, as
determined by traits_type::eq, then:
+
[(3.1.1.1)](#quoted.manip-3.1.1.1)
Turn off the skipws flag[.](#quoted.manip-3.1.1.1.sentence-1)
+
[(3.1.1.2)](#quoted.manip-3.1.1.2)
s.clear()
+
[(3.1.1.3)](#quoted.manip-3.1.1.3)
Until an unescaped delim character is reached or !in,
extract characters from in and append them to s, except that
if an escape is reached, ignore it and append the next character tos[.](#quoted.manip-3.1.1.3.sentence-1)
+
[(3.1.1.4)](#quoted.manip-3.1.1.4)
Discard the final delim character[.](#quoted.manip-3.1.1.4.sentence-1)
+
[(3.1.1.5)](#quoted.manip-3.1.1.5)
Restore the skipws flag to its original value[.](#quoted.manip-3.1.1.5.sentence-1)
* [(3.1.2)](#quoted.manip-3.1.2)
Otherwise, in >> s[.](#quoted.manip-3.1.2.sentence-1)
- [(3.2)](#quoted.manip-3.2)
If out is an instance of basic_ostream with member typeschar_type and traits_type the same as charT andtraits, respectively, then the expressionout << quoted(s, delim, escape) behaves as specified for theconst basic_string<charT, traits, Allocator>& overload of thequoted function[.](#quoted.manip-3.2.sentence-1)
- [(3.3)](#quoted.manip-3.3)
The expression in >> quoted(s, delim, escape) has typebasic_istream<charT, traits>& and value in[.](#quoted.manip-3.3.sentence-1)
- [(3.4)](#quoted.manip-3.4)
The expression out << quoted(s, delim, escape) has typebasic_ostream<charT, traits>& and value out[.](#quoted.manip-3.4.sentence-1)
### [31.7.10](#print.fun) Print functions [[print.fun]](print.fun)
[🔗](#lib:print_)
`template<class... Args>
void print(format_string<Args...> fmt, Args&&... args);
`
[1](#print.fun-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7716)
*Effects*: Equivalent to:print(stdout, fmt, std::forward<Args>(args)...);
[🔗](#lib:print__)
`template<class... Args>
void print(FILE* stream, format_string<Args...> fmt, Args&&... args);
`
[2](#print.fun-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7731)
*Effects*: Let locksafe be(enable_nonlocking_formatter_optimization<remove_cvref_t<Args>> && ...)[.](#print.fun-2.sentence-1)
If the ordinary literal encoding ([[lex.charset]](lex.charset "5.3.1Character sets")) is UTF-8, equivalent to:locksafe ? vprint_unicode(stream, fmt.str, make_format_args(args...)): vprint_unicode_buffered(stream, fmt.str, make_format_args(args...));
Otherwise, equivalent to:locksafe ? vprint_nonunicode(stream, fmt.str, make_format_args(args...)): vprint_nonunicode_buffered(stream, fmt.str, make_format_args(args...));
[🔗](#lib:println__)
`template<class... Args>
void println(format_string<Args...> fmt, Args&&... args);
`
[3](#print.fun-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7756)
*Effects*: Equivalent to:println(stdout, fmt, std::forward<Args>(args)...);
[🔗](#lib:println___)
`void println();
`
[4](#print.fun-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7770)
*Effects*: Equivalent to:println(stdout);
[🔗](#lib:println____)
`template<class... Args>
void println(FILE* stream, format_string<Args...> fmt, Args&&... args);
`
[5](#print.fun-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7785)
*Effects*: Equivalent to:print(stream, runtime_format(string(fmt.get()) + '\n'), std::forward<Args>(args)...);
[🔗](#lib:println_____)
`void println(FILE* stream);
`
[6](#print.fun-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7799)
*Effects*: Equivalent to:print(stream, "\n");
[🔗](#lib:vprint_unicode_)
`void vprint_unicode(string_view fmt, format_args args);
`
[7](#print.fun-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7813)
*Effects*: Equivalent to:vprint_unicode(stdout, fmt, args);
[🔗](#lib:vprint_unicode_buffered)
`void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args args);
`
[8](#print.fun-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7827)
*Effects*: Equivalent to:string out = vformat(fmt, args);
vprint_unicode(stream, "{}", make_format_args(out));
[🔗](#lib:vprint_unicode__)
`void vprint_unicode(FILE* stream, string_view fmt, format_args args);
`
[9](#print.fun-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7842)
*Preconditions*: stream is a valid pointer to an output C stream[.](#print.fun-9.sentence-1)
[10](#print.fun-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7846)
*Effects*: Locks stream[.](#print.fun-10.sentence-1)
Let out denote the character representation of
formatting arguments provided by args formatted according to specifications given in fmt[.](#print.fun-10.sentence-2)
- [(10.1)](#print.fun-10.1)
If stream refers to a terminal that
is capable of displaying Unicode only via a native Unicode API,
flushes stream and then
writes out to the terminal using the native Unicode API;
if out contains invalid code units,the behavior is undefined[.](#print.fun-10.1.sentence-1)
Then establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2Abstract machine"))[.](#print.fun-10.1.sentence-2)
- [(10.2)](#print.fun-10.2)
Otherwise writes out to stream unchanged[.](#print.fun-10.2.sentence-1)
Unconditionally unlocks stream on function exit[.](#print.fun-10.sentence-3)
See also: ISO/IEC 9899:2024, 7.21.2[.](#print.fun-10.sentence-4)
[*Note [1](#print.fun-note-1)*:
On Windows the native Unicode API is WriteConsoleW andstream referring to a terminal means thatGetConsoleMode(_get_osfhandle(_fileno(stream)), ...) returns nonzero[.](#print.fun-10.sentence-5)
— *end note*]
[11](#print.fun-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7876)
*Throws*: Any exception thrown by the call to vformat ([[format.err.report]](format.err.report "28.5.3Error reporting"))[.](#print.fun-11.sentence-1)
system_error if writing to the terminal or stream fails[.](#print.fun-11.sentence-2)
May throw bad_alloc[.](#print.fun-11.sentence-3)
[12](#print.fun-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7882)
*Recommended practice*: If invoking the native Unicode API requires transcoding,
implementations should substitute invalid code units
with U+fffd replacement character per
the Unicode Standard, Chapter 3.9 U+fffd Substitution in Conversion[.](#print.fun-12.sentence-1)
[🔗](#lib:vprint_nonunicode_)
`void vprint_nonunicode(string_view fmt, format_args args);
`
[13](#print.fun-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7896)
*Effects*: Equivalent to:vprint_nonunicode(stdout, fmt, args);
[🔗](#lib:vprint_nonunicode_buffered)
`void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args args);
`
[14](#print.fun-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7910)
*Effects*: Equivalent to:string out = vformat(fmt, args);
vprint_nonunicode("{}", make_format_args(out));
[🔗](#lib:vprint_nonunicode__)
`void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
`
[15](#print.fun-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7925)
*Preconditions*: stream is a valid pointer to an output C stream[.](#print.fun-15.sentence-1)
[16](#print.fun-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7929)
*Effects*: While holding the lock on stream,
writes the character representation of
formatting arguments provided by args formatted according to specifications given in fmt to stream[.](#print.fun-16.sentence-1)
[17](#print.fun-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L7936)
*Throws*: Any exception thrown by the call to vformat ([[format.err.report]](format.err.report "28.5.3Error reporting"))[.](#print.fun-17.sentence-1)
system_error if writing to stream fails[.](#print.fun-17.sentence-2)
May throw bad_alloc[.](#print.fun-17.sentence-3)