I/O manipulators | ||||
Print functions(C++23) | ||||
C-style I/O | ||||
Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
Streams | ||||
Abstractions | ||||
File I/O | ||||
String I/O | ||||
Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
Synchronized Output | ||||
(C++20) | ||||
Types | ||||
Error category interface | ||||
(C++11) | ||||
(C++11) |
Member functions | ||||
(C++11) | ||||
String operations | ||||
basic_stringstream::view (C++20) | ||||
Non-member functions | ||||
std::basic_string_view<CharT, Traits> view()constnoexcept; | (since C++20) | |
Obtains astd::basic_string_view over the underlying string object. Equivalent toreturn rdbuf()->view();.
Contents |
(none)
Astd::basic_string_view over the underlying string object.
#include <iostream>#include <sstream> int main(){// input/output streamstd::stringstream buf1; buf1<<69;int n=0; buf1>> n;std::cout<<"1) buf1 = ["<< buf1.view()<<"], n = "<< n<<'\n'; // output stream in append modestd::ostringstream buf2("test",std::ios_base::ate); buf2<<'1';std::cout<<"2) buf2 = ["<< buf2.view()<<"]\n"; // input streamstd::istringstream inbuf("-42"); inbuf>> n;std::cout<<"3) inbuf = ["<< inbuf.view()<<"], n = "<< n<<'\n';}
Output:
1) buf1 = [69], n = 692) buf2 = [test1]3) inbuf = [-42], n = -42
(C++20) | obtains a view over the underlying character sequence (public member function of std::basic_stringbuf<CharT,Traits,Allocator> )[edit] |