I'm trying to get familiar with using boost::iostreams. Looking at the iostreams tutorial, it seems this test code ought to be a trivial implementation of a sink device and the stream template:
#include <iostream>
#include <iosfwd>
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/concepts.hpp>
namespace io = boost::iostreams;
class testSink {
public:
typedef char char_type;
typedef io::sink_tag category;
std::streamsize write(const char* s, std::streamsize n) {
std::cout.write(s, n);
return n;
}
};
int main(int argc, char *argv[])
{
io::stream<testSink> out;
out << "Hello" << std::endl;
return EXIT_SUCCESS;
}
Compiling this under linux and g++ (g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)) succeeds without error, but running it crashes with an assertion failure:
/usr/local/include/boost/iostreams/detail/optional.hpp:55: T& boost::iostreams::detail::optional::operator*() [with T = boost::iostreams::detail::concept_adapter]: Assertion `initialized_' failed. Aborted (core dumped)
There is obviously some undocumented initialization step, but what?
Thanks