1
我正在使用boost :: iostream lib将posix管道包装到gnuplot。要发送的二进制在线数据GNUPLOT,我正在做这样的事情来自std :: vector的未格式化流输入<double>
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
它的工作原理,但我想摆脱.WRITE的,并使用一个Iterator接口允许例如作为源的std :: list。我知道std :: ostreambuf_iterator允许无格式输入,但简单地使用std :: copy显然不起作用。
的事情是,这将只是没有*作*与任何容器,而是一个'VECTOR',因为你是只需写入连续的内存范围而不考虑对象类型。不过,一个基于迭代器的包装器很不值钱。 – 2012-03-19 17:38:46