2

I'm currently investigating portable, idiomatic, standard library-only C++ methods of writing binary data into a std::vector<char>. I would like to interface with the container in the same manner as I would any other binary ostream, using the write() function.

So far the only thing I have turned up is inheriting from std::basic_streambuf<>. Are there any better alternatives to this?

chili
  • 665
  • 8
  • 20

1 Answers1

2

You are correct, inheriting from std::basic_streambuf is the way to do it. Not sure if you are interested, but boost::iostreams and boost::interprocess have implemented this type of stuff already:

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

Jesse Good
  • 50,901
  • 14
  • 124
  • 166