std::basic_stringstream<CharT,Traits,Allocator>::basic_stringstream
: cppreference.com
basic_stringstream() : basic_stringstream(std::ios_base::in | std::ios_base::out) { } |
(1) | (C++11) |
| (2) | ||
explicit basic_stringstream( std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out ); |
(C++11) | |
explicit basic_stringstream( std::ios_base::openmode mode ); |
(C++11) | |
explicit basic_stringstream( const std::basic_string<CharT,Traits,Allocator>& str, {{#pad:|27}} std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out ); |
(3) | |
basic_stringstream( basic_stringstream&& other ); |
(4) | (C++11) |
basic_stringstream( std::ios_base::openmode mode, const Allocator& a ); |
(5) | (C++20) |
explicit basic_stringstream( std::basic_string<CharT,Traits,Allocator>&& str, {{#pad:|27}} std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out ); |
(6) | (C++20) |
template<class SAlloc> basic_stringstream( const std::basic_string<CharT,Traits,SAlloc>& str, {{#pad:|18}} const Allocator& a ) : basic_stringstream(str, std::ios_base::in | std::ios_base::out, a) { } |
(7) | (C++20) |
template<class SAlloc> basic_stringstream( const std::basic_string<CharT,Traits,SAlloc>& str, {{#pad:|18}} std::ios_base::openmode mode, const Allocator& a ); |
(8) | (C++20) |
template<class SAlloc> explicit basic_stringstream( const std::basic_string<CharT,Traits,SAlloc>& str, {{#pad:|27}} std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out ); |
(9) | (C++20) |
1)
2)
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(mode) 3)
str basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(str, mode) 4)
other 5)
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(mode, a) 6)
str basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(std::move(str), mode) 7)
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(str, std::ios_base::in | std::ios_base::out, a) 8)
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(str, mode, a) 9)
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(str, mode) SAlloc Allocator | str | - | |||||||||||||||
| a | - | |||||||||||||||
| mode | - |
| ||||||||||||||
| other | - |
basic_stringstream str
C++
| DR | |||
|---|---|---|---|
| P0935R0 | C++11 | default constructor was explicit | made implicit |
Run this code
#include <iostream>
#include <sstream>
int main()
{
// default constructor (input/output stream)
std::stringstream buf1;
buf1 << 7;
int n = 0;
buf1 >> n;
std::cout << "buf1 = " << buf1.str() << " n = " << n << '\n';
// input stream
std::istringstream inbuf("-10");
inbuf >> n;
std::cout << "n = " << n << '\n';
// output stream in append mode (C++11)
std::ostringstream buf2("test", std::ios_base::ate);
buf2 << '1';
std::cout << buf2.str() << '\n';
}
:
buf1 = 7 n = 7
n = -10
test1
| () | |
| basic_stringbuf ( std::basic_stringbuf<CharT,Traits,Allocator>)
|