Reputation: 676
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?
Upvotes: 2
Views: 172
Reputation: 52365
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
Upvotes: 2