stringstream->rdbuf()->pubsetbuf is not setting the buffer

前端 未结 1 1381
梦谈多话
梦谈多话 2020-12-20 16:34

I am trying to modify a stringbuffer of a stringstream object without having to copy a string, using the method pubsetbuf, but it is not working. I am following the document

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 16:58

    Not should set contents. pubsetbuf calls virtual setbuf

    basic_streambuf* setbuf(charT* s, streamsize n);
    

    15 Effects: implementation-defined, except that setbuf(0,0) has no effect.

    16 Returns: this.

    VS 2010. There is no overload of virtual method setbuf in basic_stringbuf, it uses default from basic_streambuf

    virtual _Myt *__CLR_OR_THIS_CALL setbuf(_Elem *, streamsize)
        {   // offer buffer to external agent (do nothing)
        return (this);
        }
    

    0 讨论(0)
提交回复
热议问题