basic_streambuf<CharT, Traits>* pubsetbuf( char_type* s, std::streamsize n ) | (1) | |
protected: virtual basic_streambuf<CharT, Traits>* setbuf( char_type* s, std::streamsize n ) | (2) |
setbuf(s, n)
of the most derived classs | - | pointer to the first CharT in the user-provided buffer |
n | - | the number of CharT elements in the user-provided buffer |
setbuf(s, n)
this
provide a 10k buffer for reading. On linux, the strace utility may be used to observe the actual number of bytes read.
#include <fstream> #include <iostream> #include <string> int main() { int cnt = 0; std::ifstream file; char buf[10241]; file.rdbuf()->pubsetbuf(buf, sizeof buf); file.open("/usr/share/dict/words"); for (std::string line; getline(file, line);) { cnt++; } std::cout << cnt << '\n'; }
[virtual] | attempts to replace the controlled character sequence with an array (virtual protected member function of std::basic_stringbuf<CharT,Traits,Allocator> ) |
[virtual] | provides user-supplied buffer or turns this filebuf unbuffered (virtual protected member function of std::basic_filebuf<CharT,Traits> ) |
[virtual] | attempts to replace the controlled character sequence with an array (virtual protected member function of std::strstreambuf ) |
sets the buffer for a file stream (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/io/basic_streambuf/pubsetbuf