Hacker News new | ask | show | jobs
by panzi 247 days ago
Just today I saw a (2 year old) video on that very topic in Rust and C++: https://www.youtube.com/watch?v=algDLvbl1YY Towards the end they mention what to use instead in C++ to get the same characteristics as Rust's Vec::reserve:

    vec.insert(
        vec.cend(),
        std::move_iterator(newElems.begin()),
        std::move_iterator(newElems.end())
    );
1 comments

This is roughly analogous to Vec's specialised Extend implementation. Like that feature it only helps if you've got a similar API shape you're adapting. If we need to make newElems then we're probably not getting a perf win from this.