I’m using the boost::iostream lib to wrap a posix pipe to gnuplot. To send binary inline data to gnuplot, I’m currently doing something like this
std::vector<double> d = test_data();
Gnuplot plt; //custom gnuplot class derived from boost::iostream::stream
plt << "plot '-' binary format='%double' notitle\n"
plt.write( (char*)( &c.front() ), sizeof(double)*c.size() ); // send binary data
It works, but I’d like to get rid of .write and use an iterator interface to allow e.g. a std::list as source. I know std::ostreambuf_iterator allows unformatted input but simply using std::copy obviously doesn’t work.
Here’s a naive wrapper template to write out ranges:
Usage:
write_range(gp, mylist.begin(), mylist.end());