Improving efficiency of std::copy() with back_inserter() or inserter()
问题 back_inserter and insert_iterator are very handy, but they're also very inefficient! When you're appending char s, for example, there is a great deal of overhead for every element when you're copy ing, when in many situations, there really doesn't need to be. Is there a way to make them more efficient? 回答1: Yes, you can define a new version of std::copy which can hijack optimizable calls. :) Below is an example (or "hack", if you prefer to see the glass half-empty) for Visual C++ and GCC. On