std::basic_istringstream<CharT,Traits,Allocator>::view - cppreference.com (original) (raw)
I/O manipulators |
---|
Print functions (C++23) |
C-style I/O |
Buffers |
basic_streambuf |
basic_filebuf |
basic_stringbuf |
basic_spanbuf(C++23) |
strstreambuf(C++98/26*) |
basic_syncbuf(C++20) |
Streams |
Abstractions |
ios_base |
basic_ios |
basic_istream |
basic_ostream |
basic_iostream |
File I/O |
basic_ifstream |
basic_ofstream |
basic_fstream |
String I/O |
basic_istringstream |
basic_ostringstream |
basic_stringstream |
Array I/O |
basic_ispanstream(C++23) |
basic_ospanstream(C++23) |
basic_spanstream(C++23) |
istrstream(C++98/26*) |
ostrstream(C++98/26*) |
strstream(C++98/26*) |
Synchronized Output |
basic_osyncstream(C++20) |
Types |
streamoff |
streamsize |
fpos |
Error category interface |
iostream_category(C++11) |
io_errc(C++11) |
Member functions |
---|
basic_istringstream::basic_istringstream |
basic_istringstream::operator= |
basic_istringstream::swap(C++11) |
basic_istringstream::rdbuf |
String operations |
basic_istringstream::str |
basic_istringstream::view(C++20) |
Non-member functions |
swap(std::basic_istringstream)(C++11) |
| std::basic_string_view<CharT, Traits> view() const noexcept; | | (since C++20) | | ---------------------------------------------------------------------------------------------------------- | | ------------- |
Obtains a std::basic_string_view over the underlying string object. Equivalent to return rdbuf()->view();.
Contents
[edit] Parameters
(none)
[edit] Return value
A std::basic_string_view over the underlying string object.
[edit] Example
Run this code
#include #include int main() { // input/output stream std::stringstream buf1; buf1 << 69; int n = 0; buf1 >> n; std::cout << "1) buf1 = [" << buf1.view() << "], n = " << n << '\n'; // output stream in append mode std::ostringstream buf2("test", std::ios_base::ate); buf2 << '1'; std::cout << "2) buf2 = [" << buf2.view() << "]\n"; // input stream std::istringstream inbuf("-42"); inbuf >> n; std::cout << "3) inbuf = [" << inbuf.view() << "], n = " << n << '\n'; }
Output:
- buf1 = [69], n = 69
- buf2 = [test1]
- inbuf = [-42], n = -42
[edit] See also
view(C++20) | obtains a view over the underlying character sequence (public member function of std::basic_stringbuf<CharT,Traits,Allocator>) [edit] |
---|