Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::basic_...stream::view(3) C++ Standard Libarystd::basic_...stream::view(3)

NAME
       std::basic_stringstream::view - std::basic_stringstream::view

Synopsis
	  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();.

Parameters
	  (none)

Return value
	  A std::basic_string_view over	the underlying string object.

Example
       // Run this code

	#include <iostream>
	#include <sstream>

	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:
	1) buf1	= [69],	n = 69
	2) buf2	= [test1]
	3) inbuf = [-42], n = -42

See also
	  view	  obtains a view over the underlying character sequence
	  (C++20)    (public	member	  function    of    std::basic_string-
       buf<CharT,Traits,Allocator>)

http://cppreference.com		  2024.06.10	 std::basic_...stream::view(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::stringstream::view&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help