此问题与prior question of mine有关。我使用下面的代码检查与streambuf
关联的cout
对象中的值。使用VS2010 IDE,我可以在这个类中看到几个成员。任何人都可以指向我这些成员中的哪一个指向内存中的cout的空缓冲区?
#include <iostream>
int main()
{
std::streambuf* p = std::cout.rdbuf();
}
修改:查看streambuf
标题文件,可以在basic_streambuf
类中找到以下私有成员:
_Mutex _Mylock; // thread lock
_Elem *_Gfirst; // beginning of read buffer
_Elem *_Pfirst; // beginning of write buffer
_Elem **_IGfirst; // pointer to beginning of read buffer
_Elem **_IPfirst; // pointer to beginning of write buffer
_Elem *_Gnext; // current position in read buffer
_Elem *_Pnext; // current position in write buffer
_Elem **_IGnext; // pointer to current position in read buffer
_Elem **_IPnext; // pointer to current position in write buffer
int _Gcount; // length of read buffer
int _Pcount; // length of write buffer
int *_IGcount; // pointer to length of read buffer
int *_IPcount; // pointer to length of write buffer
locale *_Plocale; // pointer to imbued locale object
我相信_Pfirst
是我正在寻找的地址,并且按预期为空。