streambuf类的哪个成员指向内存中的实际缓冲区?

时间:2013-02-10 19:09:55

标签: c++ visual-studio-2010 stream cout streambuf

此问题与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是我正在寻找的地址,并且按预期为空。

0 个答案:

没有答案