write to a zipped back inserted ranges

孤者浪人 提交于 2019-12-11 11:54:15

问题


A close cousin of this other question, but with back_inserter:

#include <range/v3/view.hpp>
#include <range/v3/view/zip.hpp>
#include <range/v3/utility/iterator.hpp>

// ...

std::vector< std::tuple<int, std::string, double> > const data{
   {1,"a", 3.14},
   {2,"b", 42.0},
   {3,"c"}
};
std::vector<int> vi;
std::vector<std::string> vs;
std::vector<double> vd;

using namespace ranges;
copy(data,  view::zip(
   back_inserter(vi),
   back_inserter(vs),
   back_inserter(vd)) );

This is obviously an error because back_inserter() is an iterator, and zip is expecting a range. But how to accomplish zipping into a back inserted ranges?

来源:https://stackoverflow.com/questions/54895996/write-to-a-zipped-back-inserted-ranges

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!