草庐IT

stringbuf

全部标签

c++ - 为什么 basic_stringbuf 和 basic_filebuf 移动构造函数具有实现定义的行为?

来self的C++标准拷贝[§27.8.2.1p4]:basic_stringbuf(basic_stringbuf&&rhs);Effects:Moveconstructsfromthervaluerhs.Itisimplementation-definedwhetherthesequencepointersin*this(eback(),gptr(),egptr(),pbase(),pptr(),epptr())obtainthevalueswhichrhshad.Whethertheydoornot,*thisandrhsreferenceseparatebuffers(ifan

c++ - 性能 stringbuf 与字符串

当我们必须处理字符串操作时,std::string和std::stringbuf之间是否存在任何显着的性能差异,如果是,为什么。更一般地说,什么时候最好使用std::stringbuf而不是std::string? 最佳答案 std::stringbuf在内部使用一个字符串来缓冲数据,所以它可能有点慢。不过,我认为差异不会很大,因为它基本上只是授权。为确保您必须运行一些性能测试。std::stringbuf在您希望IO流使用字符串作为缓冲区时很有用(例如std::stringstream,它使用std::stringbuf默认情况下

c++ - 请帮我理解streambuf、stringbuf和stringstream之间的区别?

请有人帮助我了解“streambuf、stringbuf和stringstream”之间的区别。voidf1(std::stringconst&text){std::stringstreaminStream(text);cout或者如果我写voidf2(std::stringconst&text){std::stringbufinStream(text);cout两者都显示相同的结果。什么时候应该使用stringbuf或stringstream?提前致谢。 最佳答案 stringbuf被stringstream使用,它为流提供缓冲区

c++ - 请帮我理解streambuf、stringbuf和stringstream之间的区别?

请有人帮助我了解“streambuf、stringbuf和stringstream”之间的区别。voidf1(std::stringconst&text){std::stringstreaminStream(text);cout或者如果我写voidf2(std::stringconst&text){std::stringbufinStream(text);cout两者都显示相同的结果。什么时候应该使用stringbuf或stringstream?提前致谢。 最佳答案 stringbuf被stringstream使用,它为流提供缓冲区

java - C++ 等效于 Java ByteBuffer?

我正在寻找JavaByteBuffer的C++“等效”。我可能遗漏了明显的内容,或者只需要一个孤立的用法示例来澄清。我浏览了iostream系列,看起来它可以提供一个基础。具体来说,我希望能够:从字节数组/点构建缓冲区并从缓冲区中获取原语,例如getByte,getInt使用原语构建缓冲区,例如putByte,putInt然后得到字节数组/指针。 最佳答案 你有stringbuf,filebuf或者你可以使用vector.这是一个使用stringbuf的简单示例:std::stringbufbuf;chardata[]={0,1,2

java - C++ 等效于 Java ByteBuffer?

我正在寻找JavaByteBuffer的C++“等效”。我可能遗漏了明显的内容,或者只需要一个孤立的用法示例来澄清。我浏览了iostream系列,看起来它可以提供一个基础。具体来说,我希望能够:从字节数组/点构建缓冲区并从缓冲区中获取原语,例如getByte,getInt使用原语构建缓冲区,例如putByte,putInt然后得到字节数组/指针。 最佳答案 你有stringbuf,filebuf或者你可以使用vector.这是一个使用stringbuf的简单示例:std::stringbufbuf;chardata[]={0,1,2

c++ - 正确重载 stringbuf 以替换 MATLAB mex 文件中的 cout

MathWorks目前不允许您在MATLAB桌面打开时使用mex文件中的cout,因为它们已重定向标准输出。他们当前的解决方法是提供一个函数,mexPrintf,thattheyrequestyouuseinstead.在谷歌搜索了一下之后,我认为可以扩展std::stringbuf类来完成我需要的事情。这是我到目前为止所拥有的。这是否足够健壮,或者是否有其他方法需要重载或更好的方法来做到这一点?(寻找通用UNIX环境中的可移植性以及如果此代码未链接到mex可执行文件,则能够正常使用std::cout)classmstream:publicstringbuf{public:virtua