gpt4 book ai didi

c++ - 使用二进制 write() read() 将 vector 作为流连接

转载 作者:行者123 更新时间:2023-11-30 03:31:42 27 4
gpt4 key购买 nike

我目前正在研究将二进制数据写入 std::vector<char> 的可移植的、惯用的、仅限标准库的 C++ 方法。 .我想以与任何其他二进制 ostream 相同的方式与容器交互,使用 write() 函数。

到目前为止,我唯一发现的是继承自 std::basic_streambuf<> .有没有更好的替代方案?

最佳答案

你是对的,从 std::basic_streambuf 继承是实现它的方法。不确定你是否感兴趣,但是 boost::iostreams 和 boost::interprocess 已经实现了这种类型的东西:

http://www.boost.org/doc/libs/1_64_0/libs/iostreams/doc/index.html http://www.boost.org/doc/libs/1_64_0/doc/html/interprocess/streams.html

关于c++ - 使用二进制 write() read() 将 vector<char> 作为流连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43992095/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com