std::basic_ospanstream(3)
π NAME π
std::basic_ospanstreamβstd::basic_ospanstream- Manual name:
std::basic_ospanstream(3)from the C++ Standard Libary, bestie π«Ά
β¨ Synopsis β¨
Okay so first things first: it's defined in header <spanstream>, and the template situation is literally this:
template<
class CharT,
class Traits = std::char_traits<CharT> (since C++23)
> class basic_ospanstream
: public basic_ostream<CharT, Traits>
The class template std::basic_ospanstream is the one that implements output operations on streams based on fixed buffers. Slay.
At the low level, this class essentially wraps a raw device implementation of std::basic_spanbuf into a higher-level interface of std::basic_ostream. The complete interface to unique std::basic_spanbuf members is provided β no crumbs, full access, periodt.
std-basic ospanstream-inheritance.svg β Inheritance diagram π¦
Several typedefs for common character types are provided, and yes they're defined in header <spanstream> too:
std::ospanstreamβstd::basic_ospanstream<char>std::wospanstreamβstd::basic_ospanstream<wchar_t>
π Member types π
char_typeβCharTtraits_typeβTraits; the program is ill-formed ifTraits::char_typeis notCharT.int_typeβTraits::int_typepos_typeβTraits::pos_typeoff_typeβTraits::off_type
πΈ Data members πΈ
sb(private) β the wrappedstd::basic_spanbuf. (exposition-only member object*)
π Member functions π
- constructor (
C++23) β constructs thebasic_ospanstream(public member function) - destructor
[virtual](C++23) β destroys thebasic_ospanstream(virtual public member function) operator=(C++23) β move-assignments thebasic_ospanstream(public member function)swap(C++23) β swaps twobasic_ospanstreamobjects (public member function)rdbuf(C++23) β obtains the address of the wrapped raw span device object (public member function)
π§ Underlying buffer operations π§
span(C++23) β gets or sets the underlying buffer of the wrapped span device object (public member function)
π₯ Non-member functions π₯
std::swap(std::basic_ospanstream)β specializes thestd::swapalgorithm (C++23) (function template)
π Inherited from std::basic_ostream π
π Member functions π
Formatted output
operator<<β inserts formatted data (public member function ofstd::basic_ostream<CharT,Traits>)
Unformatted output
putβ inserts a character (public member function ofstd::basic_ostream<CharT,Traits>)writeβ inserts blocks of characters (public member function ofstd::basic_ostream<CharT,Traits>)
Positioning
tellpβ returns the output position indicator (public member function ofstd::basic_ostream<CharT,Traits>)seekpβ sets the output position indicator (public member function ofstd::basic_ostream<CharT,Traits>)
Miscellaneous
flushβ synchronizes with the underlying storage device (public member function ofstd::basic_ostream<CharT,Traits>)
π¦ Member classes π¦
sentryβ implements basic logic for preparation of the stream for output operations (public member class ofstd::basic_ostream<CharT,Traits>)
π Inherited from std::basic_ios π
β¨ Member types β¨
char_typeβCharTtraits_typeβTraitsint_typeβTraits::int_typepos_typeβTraits::pos_typeoff_typeβTraits::off_type
π Member functions π
State functions
goodβ checks if no error has occurred i.e. I/O operations are available (public member function ofstd::basic_ios<CharT,Traits>)eofβ checks if end-of-file has been reached (public member function ofstd::basic_ios<CharT,Traits>)failβ checks if an error has occurred (public member function ofstd::basic_ios<CharT,Traits>)badβ checks if a non-recoverable error has occurred (public member function ofstd::basic_ios<CharT,Traits>)operator!β checks if an error has occurred (synonym offail()) (public member function ofstd::basic_ios<CharT,Traits>)operator boolβ checks if no error has occurred (synonym of!fail()) (public member function ofstd::basic_ios<CharT,Traits>)rdstateβ returns state flags (public member function ofstd::basic_ios<CharT,Traits>)setstateβ sets state flags (public member function ofstd::basic_ios<CharT,Traits>)clearβ modifies state flags (public member function ofstd::basic_ios<CharT,Traits>)
Formatting
copyfmtβ copies formatting information (public member function ofstd::basic_ios<CharT,Traits>)fillβ manages the fill character (public member function ofstd::basic_ios<CharT,Traits>)
Miscellaneous
exceptionsβ manages exception mask (public member function ofstd::basic_ios<CharT,Traits>)imbueβ sets the locale (public member function ofstd::basic_ios<CharT,Traits>)rdbufβ manages associated stream buffer (public member function ofstd::basic_ios<CharT,Traits>)tieβ manages tied stream (public member function ofstd::basic_ios<CharT,Traits>)narrowβ narrows characters (public member function ofstd::basic_ios<CharT,Traits>)widenβ widens characters (public member function ofstd::basic_ios<CharT,Traits>)
π«Ά Inherited from std::ios_base π«Ά
π Member functions π
Formatting
flagsβ manages format flags (public member function ofstd::ios_base)setfβ sets specific format flag (public member function ofstd::ios_base)unsetfβ clears specific format flag (public member function ofstd::ios_base)precisionβ manages decimal precision of floating point operations (public member function ofstd::ios_base)widthβ manages field width (public member function ofstd::ios_base)
Locales
imbueβ sets locale (public member function ofstd::ios_base)getlocβ returns current locale (public member function ofstd::ios_base)
Internal extensible array
xalloc[static]β returns a program-wide unique integer that is safe to use as index topword()andiword()(public static member function ofstd::ios_base)iwordβ resizes the private storage if necessary and access to thelongelement at the given index (public member function ofstd::ios_base)pwordβ resizes the private storage if necessary and access to thevoid*element at the given index (public member function ofstd::ios_base)
Miscellaneous
register_callbackβ registers event callback function (public member function ofstd::ios_base)sync_with_stdio[static]β sets whether C++ and C I/O libraries are interoperable (public static member function ofstd::ios_base)
π Member classes π
failureβ stream exception (public member class ofstd::ios_base)Initβ initializes standard stream objects (public member class ofstd::ios_base)
β¨ Member types and constants β¨
okay bestie, this is the type-and-constant lineup, and it's genuinely a lot π no cap, every single one matters, so let's go.
openmode (typedef) β stream open mode type
The following constants are also defined:
appβ seek to the end of stream before each writebinaryβ open in binary modeinβ open for readingoutβ open for writingtruncβ discard the contents of the stream when openingateβ seek to the end of stream immediately after opennoreplace(C++23) β open in exclusive mode
fmtflags (typedef) β formatting flags type
The following constants are also defined:
decβ use decimal base for integer I/O: seestd::decoctβ use octal base for integer I/O: seestd::octhexβ use hexadecimal base for integer I/O: seestd::hexbasefieldβdec | oct | hex. Useful for masking operationsleftβ left adjustment (adds fill characters to the right): seestd::leftrightβ right adjustment (adds fill characters to the left): seestd::rightinternalβ internal adjustment (adds fill characters to the internal designated point): seestd::internaladjustfieldβleft | right | internal. Useful for masking operationsscientificβ generate floating point types using scientific notation, or hex notation if combined with fixed: seestd::scientificfixedβ generate floating point types using fixed notation, or hex notation if combined with scientific: seestd::fixedfloatfieldβscientific | fixed. Useful for masking operationsboolalphaβ insert and extractbooltype in alphanumeric format: seestd::boolalphashowbaseβ generate a prefix indicating the numeric base for integer output, require the currency indicator in monetary I/O: seestd::showbaseshowpointβ generate a decimal-point character unconditionally for floating-point number output: seestd::showpointshowposβ generate a+character for non-negative numeric output: seestd::showposskipwsβ skip leading whitespace before certain input operations: seestd::skipwsunitbufβ flush the output after each output operation: seestd::unitbufuppercaseβ replace certain lowercase letters with their uppercase equivalents in certain output operations: seestd::uppercase
iostate (typedef) β state of the stream type
The following constants are also defined:
goodbitβ no errorbadbitβ irrecoverable stream errorfailbitβ input/output operation failed (formatting or extraction error)eofbitβ associated input sequence has reached end-of-file
seekdir (typedef) β seeking direction type
The following constants are also defined:
begβ the beginning of a streamendβ the ending of a streamcurβ the current position of stream position indicator
event (enum) β specifies event type
event_callback (typedef) β callback function type
π Notes π
Feature-test macro time, bestie β this is the little receipt that tells you the feature exists:
- Feature-test macro:
__cpp_lib_spanstream - Value:
202106L - Std:
(C++23) - Feature:
std::spanbuf,std::spanstream
That's the whole vibe check, bestie π«Ά page source is cppreference.com, source/version date is 2024.06.10, and this iconic little manual page is std::basic_ospanstream(3). Stay slay, keep your streams safe, and may your flags always be exactly where you left them π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms