c++ - std::fstream 和 Boost Iostreams 库之间的区别

标签 c++ boost stl

我是 BOOST 库的新手。今天看到一小段代码,其中读写PGM格式图片是用Boost Iostreams Library实现的。随着我对 STL 越来越熟悉,我可以很容易地看出 std::fstream 可以完成同样的工作。那么我的问题是,在这样一个简单的读写PGM图像的应用程序中使用Boost库有什么意义呢?此外,我想知道在什么情况下最需要 BOOST Iostreams 库。谢谢!

最佳答案

来自 std::fstream reference :

fstream provides an interface to read and write data from files as input/output streams.

来自 Boost.Iostreams reference :

Boost.Iostreams has three aims:

  • To make it easy to create standard C++ streams and stream buffers for accessing new Sources and Sinks.
  • To provide a framework for defining Filters and attaching them to standard streams and stream buffers.
  • To provide a collection of ready-to-use Filters, Sources and Sinks.

关于c++ - std::fstream 和 Boost Iostreams 库之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12251128/

相关文章:

c++ - 无法在 Visual C++ 2010 中运行我的第一个 Win32 应用程序

c++ - 是否有一个分配器使用 alloca 并且在其他方​​面与 C++ STL 兼容?

c++ - VS2005中包含头文件

c++ - 线程和非线程函数调用的执行顺序是什么?

c++ - 在 C++ 中实现泛型堆栈

c++ - 在 C++ 中模拟来自 C# 的 ContainsKey (Key) - 什么是最佳实践?

C++ : Pick portions/data from a string having fixed format

c++ - 解锁无主互斥体

c++ - Boost::Spirit 简单语法示例

c++ - VisualAssist 找不到 boost::bind 的声明