CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 24 Jul 2025 15:07:48 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/ostream/basic_ostream/basic_ostream/
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 24 Jul 2025 15:07:48 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"731a-iyZJQTEdhkAIigqbAOc+eznYd+A"
Content-Encoding: gzip
Constructs a basic_ostream object.
This code uses a filebuf object (derived from streambuf) to open the file
Objects of class ostream are seldom constructed directly. Generally some derived class is used (like the standard basic_ofstream and basic_ostringstream).
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
basic_ostream
- basic_ostream::~basic_ostream
- basic_ostream::basic_ostream
member classes
member functions
non-member overloads
protected members
-
basic_ostream::operator=C++11
-
basic_ostream::swapC++11
-
- Reference
- <ostream>
- basic_ostream
- basic_ostream
public member function
<ostream> <iostream>
std::basic_ostream::basic_ostream
initialization (1) | explicit basic_ostream (basic_streambuf<char_type,traits_type>* sb); |
---|
initialization (1) | explicit basic_ostream (basic_streambuf<char_type,traits_type>* sb); |
---|---|
copy (2) | basic_ostream& (const basic_ostream&) = delete; |
move (3) | protected: basic_ostream& (basic_ostream&& x); |
Construct object
- (1) inititalization constructor
- Assigns initial values to the components of its base classes by calling the inherited member basic_ios::init with sb as argument.
- (2) copy constructor (deleted)
- Deleted: no copy constructor.
- (3) move constructor (protected)
- Acquires the contents of x, except its associated stream buffer: It calls basic_ios::move to transfer x's internal components inherited from basic_ios. x is left with its associated stream buffer unchanged and not tied (all other components of x are in an unspecified but valid state after the call).
Parameters
- sb
- pointer to a basic_streambuf object with the same template parameters as the basic_ostream object.
char_type and traits_type are member types defined as aliases of the first and second class template parameters, respectively (see basic_ostream types). - x
- Another basic_ostream of the same type (with the same class template arguments charT and traits).
Example
|
|
This code uses a filebuf object (derived from streambuf) to open the file
test.txt
. The buffer is then passed as parameter to the ostream constructor, associating it to the stream.Objects of class ostream are seldom constructed directly. Generally some derived class is used (like the standard basic_ofstream and basic_ostringstream).
Data races
The object pointed by sb may be accessed and/or modified.Exception safety
If an exception is thrown, the only side effects may come from accessing/modifying sb.See also
- basic_ios::init
- Initialize object (protected member function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us