vector push_back over std::copy
问题 I have a function which has an unordered set as a parameter . Since I am using openmp I am converting this unordered set to vector . I use a std::copy for this conversion . //pseudo code func( std::unorderedset s1) begin vector v1; std::copy(s1.begin,s2.end,std::back_inserter(v1.end()); #openmp scope for( i = 0 ; i < v1.size(); i++ ) { //accessing v1(i) } end However I feel std::copy is a costly operation . So what I think is, if I create a class variable vector and I keep populating this