std::basic_streambuf<CharT,Traits>::sgetn, std::basic_streambuf<CharT,Traits>::xsgetn
From cppreference.com
< cpp | io | basic streambuf
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Input/output library
Print functions (C++23)
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)
std::basic_streambuf
Public member functions
Locales
Positioning
Get area
basic_streambuf::sgetn
Put area
Putback
Protected member functions
(C++11)
(C++11)
Locales
Positioning
Get area
basic_streambuf::xsgetn
Put area
Putback
std::streamsize sgetn( char_type* s, std::streamsize count );
(1)
protected:
virtual std::streamsize xsgetn( char_type* s, std::streamsize count );
(2)
virtual std::streamsize xsgetn( char_type* s, std::streamsize count );
1) Calls
xsgetn(s, count)
of the most derived class.2) Reads
count
characters from the input sequence and stores them into a character array pointed to by s
. The characters are read as if by repeated calls to sbumpc() . That is, if less than count
characters are immediately available, the function calls uflow() to provide more until Traits::eof() is returned. Classes derived from
std::basic_streambuf
are permitted to provide more efficient implementations of this function.Contents
[edit] Parameters
s
-
pointer to the beginning of a char_type array
count
-
maximum number of characters to read.
[edit] Return value
The number of characters successfully read. If it is less than count
the input sequence has reached the end.
[edit] Notes
The rule about "more efficient implementations" permits bulk I/O without intermediate buffering: that's how std::ifstream::read simply passes the pointer to the POSIX read()
system call in some implementations of iostreams
[edit] Example
This section is incomplete
Reason: no example
Reason: no example