Код: Выделить всё
#include
#include
#include
typedef std::vector PointVector;
int main(int argc, char** argv)
{
size_t n_points = 2000;
PointVector raw_points;
//
for(size_t idx = 0; idx < n_points; idx++)
raw_points.push_back( Eigen::Vector3d(idx, 0, 0));
//
PointVector proc_points;
proc_points.reserve(raw_points.size());
//
tbb::blocked_range range_(0, raw_points.size());
//
tbb::parallel_for(range_,
[&](const tbb::blocked_range& sub_range_){
for(size_t it_ = sub_range_.begin();
it_ != sub_range_.end(); it_++)
{
proc_points.emplace(proc_points.begin() + it_, raw_points.at(it_));
}
});
proc_points.shrink_to_fit();
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79804387/using-tbbparallel-for-with-reserve-and-emplace-does-not-copy-all-elements-betw[/url]