The example (reproduced below from here) shows that, using a stream of array_sink, I can get output stream functionality on a char array.
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream.hpp>
#include <iostream>
using namespace boost::iostreams;
int main()
{
char buffer[16];
array_sink sink{buffer};
stream<array_sink> os{sink};
os << "Boost" << std::flush;
std::cout.write(buffer, 5);
}
What I need though is to get a stream of array_sink from a boost::array. e.g.
...
using namespace boost::iostreams;
boost::array<char, 16384> headerBuf;
array_sink sink {headerBuf};
stream<array_sink> os {sink};
os << "somedata";
when compiling this under gcc 4.4.7, I get the error:
error: no matching function for call to ‘boost::iostreams::basic_array_sink<char>::basic_array_sink(<brace-enclosed initializer list>)’
I'm guessing the initializer list may not be supported by gcc 4.4.7, although in general, is there an alternative method of initializing an array_sink with a boost::array ?
http://www.boost.org/doc/libs/1_44_0/libs/iostreams/doc/classes/array.html#array_sink
Use the begin/end or begin/length ctors.
array_sink sink {headerBuf.begin(), headerBuf.size()};