简体   繁体   中英

Difference between std::fstream and Boost Iostreams Library

I am a newbie of BOOST library. Today I saw a small code segment, where reading and writing a PGM format image was implemented with Boost Iostreams Library. As I am more familiar with STL, I can easily tell that std::fstream can do the same job. Then my question is, what's the point of using Boost library in such a simple reading and writing PGM image application? Moreover, I was wondering in which situation BOOST Iostreams Library is most needed. Thanks!

From std::fstream reference :

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

From 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM