std::basic_streambuf<CharT,Traits>:: pbump
| 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)
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
protected
:
void pbump ( int count ) ; |
||
将
放置指针
(
pptr()
)重新定位
count
个字符,其中
count
可为正或负值。该操作不会检查指针是否移出放置区域
[
pbase
(
)
,
epptr
(
)
)
。
如果指针前进后调用 overflow() 将放置区刷新到关联的字符序列,其效果是输出了额外 count 个具有未定义值的字符。
目录 |
参数
| count | - | 要添加到放置指针的数值 |
返回值
(无)
注释
由于此函数接受一个 int 参数,它无法操作超过 std:: numeric_limits < int > :: max ( ) 字符长度的缓冲区( LWG issue 255 )。
示例
#include <fstream> #include <iostream> #include <string> struct showput_streambuf : std::filebuf { using std::filebuf::pbump; // 暴露受保护成员 std::string showput() const { return std::string(pbase(), pptr()); } }; int main() { showput_streambuf mybuf; mybuf.open("test.txt", std::ios_base::out); std::ostream str(&mybuf); str << "This is a test" << std::flush << "1234"; std::cout << "The put area contains: " << mybuf.showput() << '\n'; mybuf.pbump(10); std::cout << "after pbump(10), it contains " << mybuf.showput() << '\n'; }
输出:
The put area contains: 1234 after pbump(10), it contains 1234 is a test
参见
|
推进输入序列中的下一个指针
(受保护成员函数) |