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