Difference between revisions of "cpp/io/basic ostream"
m (1 revision: import content) |
Andreas Krug (Talk | contribs) m (fmt) |
||
(27 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|basic_ostream}} | {{cpp/title|basic_ostream}} | ||
− | {{cpp/io/basic_ostream/ | + | {{cpp/io/basic_ostream/navbar}} |
− | {{ddcl | header=ostream | | + | {{ddcl|header=ostream|1= |
template< | template< | ||
class CharT, | class CharT, | ||
− | class Traits | + | class Traits = std::char_traits<CharT> |
− | > class basic_ostream | + | > class basic_ostream : virtual public std::basic_ios<CharT, Traits> |
}} | }} | ||
− | + | The class template {{tt|basic_ostream}} provides support for high level output operations on character streams. The supported operations include formatted output (e.g. integer values) and unformatted output (e.g. raw characters and character arrays). This functionality is implemented in terms of the interface provided by the {{tt|basic_streambuf}} class, accessed through the {{tt|basic_ios}} base class. In typical implementations, {{tt|basic_ostream}} has no non-inherited data members. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | {{inheritance diagram/std-basic_ostream}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | {{cpp/basic char typedefs|ostream}} | |
− | {{ | + | ===Global objects=== |
− | {{ | + | Six global {{tt|basic_ostream}} objects are provided by the standard library: |
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc header|iostream}} |
− | {{ | + | {{dsc inc|cpp/io/dsc cout}} |
− | {{ | + | {{dsc inc|cpp/io/dsc cerr}} |
+ | {{dsc inc|cpp/io/dsc clog}} | ||
+ | {{dsc end}} | ||
− | + | {{cpp/io/member types}} | |
− | + | ===Member functions=== | |
− | + | {{dsc begin}} | |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc constructor}} | |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc destructor}} | |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc operator{{=}}}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | {{ | + | {{dsc h2|Formatted output}} |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc operator_ltlt}} | |
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | {{ | + | {{dsc h2|Unformatted output}} |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc put}} | |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc write}} |
− | {{ | + | |
− | {{ | + | {{dsc h2|Positioning}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc tellp}} |
+ | {{dsc inc|cpp/io/basic_ostream/dsc seekp}} | ||
− | {{ | + | {{dsc h2|Miscellaneous}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc flush}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc swap}} |
+ | {{dsc end}} | ||
− | {{ | + | ===Member classes=== |
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc sentry}} |
+ | {{dsc end}} | ||
− | {{ | + | ===Non-member functions=== |
− | {{ | + | {{dsc begin}} |
− | + | {{dsc inc|cpp/io/basic_ostream/dsc operator_ltlt2}} | |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc print}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc println}} |
− | {{ | + | {{dsc inc|cpp/io/basic_ostream/dsc vprint_unicode}} |
+ | {{dsc inc|cpp/io/basic_ostream/dsc vprint_nonunicode}} | ||
+ | {{dsc end}} | ||
{{cpp/io/basic_ios/inherit}} | {{cpp/io/basic_ios/inherit}} | ||
{{cpp/io/ios_base/inherit}} | {{cpp/io/ios_base/inherit}} | ||
+ | |||
+ | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} |
Latest revision as of 02:37, 7 December 2023
Defined in header <ostream>
|
||
template< class CharT, |
||
The class template basic_ostream
provides support for high level output operations on character streams. The supported operations include formatted output (e.g. integer values) and unformatted output (e.g. raw characters and character arrays). This functionality is implemented in terms of the interface provided by the basic_streambuf
class, accessed through the basic_ios
base class. In typical implementations, basic_ostream
has no non-inherited data members.
Inheritance diagram
Several typedefs for common character types are provided:
Defined in header
<ostream> | |
Type | Definition |
std::ostream
|
std::basic_ostream<char> |
std::wostream
|
std::basic_ostream<wchar_t> |
Contents |
[edit] Global objects
Six global basic_ostream
objects are provided by the standard library:
Defined in header
<iostream> | |
writes to the standard C output stream stdout (global object) | |
writes to the standard C error stream stderr, unbuffered (global object) | |
writes to the standard C error stream stderr (global object) |
[edit] Member types
Member type | Definition |
char_type
|
CharT
|
traits_type
|
Traits ; the program is ill-formed if Traits::char_type is not CharT .
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
[edit] Member functions
constructs the object (public member function) | |
[virtual] |
destructs the object (virtual public member function) |
(C++11) |
move-assigns from another basic_ostream (protected member function) |
Formatted output | |
inserts formatted data (public member function) | |
Unformatted output | |
inserts a character (public member function) | |
inserts blocks of characters (public member function) | |
Positioning | |
returns the output position indicator (public member function) | |
sets the output position indicator (public member function) | |
Miscellaneous | |
synchronizes with the underlying storage device (public member function) | |
(C++11) |
swaps stream objects, except for the associated buffer (protected member function) |
[edit] Member classes
implements basic logic for preparation of the stream for output operations (public member class) |
[edit] Non-member functions
inserts character data or insert into rvalue stream (function template) | |
(C++23) |
outputs formatted representation of the arguments (function template) |
(C++23) |
outputs formatted representation of the arguments with appended '\n' (function template) |
(C++23) |
performs Unicode aware output using type-erased argument representation (function) |
outputs character data using type-erased argument representation (function) |
Inherited from std::basic_ios
Member types
Member type | Definition |
char_type
|
CharT
|
traits_type
|
Traits
|
int_type
|
Traits::int_type
|
pos_type
|
Traits::pos_type
|
off_type
|
Traits::off_type
|
Member functions
State functions | |
checks if no error has occurred i.e. I/O operations are available (public member function of std::basic_ios<CharT,Traits> )
| |
checks if end-of-file has been reached (public member function of std::basic_ios<CharT,Traits> )
| |
checks if an error has occurred (public member function of std::basic_ios<CharT,Traits> )
| |
checks if a non-recoverable error has occurred (public member function of std::basic_ios<CharT,Traits> )
| |
checks if an error has occurred (synonym of fail()) (public member function of std::basic_ios<CharT,Traits> )
| |
checks if no error has occurred (synonym of ! fail()) (public member function of std::basic_ios<CharT,Traits> )
| |
returns state flags (public member function of std::basic_ios<CharT,Traits> )
| |
sets state flags (public member function of std::basic_ios<CharT,Traits> )
| |
modifies state flags (public member function of std::basic_ios<CharT,Traits> )
| |
Formatting | |
copies formatting information (public member function of std::basic_ios<CharT,Traits> )
| |
manages the fill character (public member function of std::basic_ios<CharT,Traits> )
| |
Miscellaneous | |
manages exception mask (public member function of std::basic_ios<CharT,Traits> )
| |
sets the locale (public member function of std::basic_ios<CharT,Traits> )
| |
manages associated stream buffer (public member function of std::basic_ios<CharT,Traits> )
| |
manages tied stream (public member function of std::basic_ios<CharT,Traits> )
| |
narrows characters (public member function of std::basic_ios<CharT,Traits> )
| |
widens characters (public member function of std::basic_ios<CharT,Traits> )
|
Inherited from std::ios_base
Member functions
Formatting | |
manages format flags (public member function of std::ios_base )
| |
sets specific format flag (public member function of std::ios_base )
| |
clears specific format flag (public member function of std::ios_base )
| |
manages decimal precision of floating point operations (public member function of std::ios_base )
| |
manages field width (public member function of std::ios_base )
| |
Locales | |
sets locale (public member function of std::ios_base )
| |
returns current locale (public member function of std::ios_base )
| |
Internal extensible array | |
[static] |
returns a program-wide unique integer that is safe to use as index to pword() and iword() (public static member function of std::ios_base )
|
resizes the private storage if necessary and access to the long element at the given index (public member function of std::ios_base )
| |
resizes the private storage if necessary and access to the void* element at the given index (public member function of std::ios_base )
| |
Miscellaneous | |
registers event callback function (public member function of std::ios_base )
| |
[static] |
sets whether C++ and C I/O libraries are interoperable (public static member function of std::ios_base )
|
Member classes | |
stream exception (public member class of std::ios_base )
| |
initializes standard stream objects (public member class of std::ios_base )
|
Member types and constants | |||||||||||||||||||||||||||||||||||||||
Type | Explanation | ||||||||||||||||||||||||||||||||||||||
stream open mode type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
formatting flags type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
state of the stream type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
seeking direction type
The following constants are also defined:
(typedef) | |||||||||||||||||||||||||||||||||||||||
specifies event type (enum) | |||||||||||||||||||||||||||||||||||||||
callback function type (typedef) |