Discussion
Team LiB
Previous Section Next Section

Discussion

The more context you can give a function, the better the chances that it can do something useful with the information. In particular, when you call a single function and pass it a pair of iterators first and last that delimit a range, it can perform optimizations based on knowing the number of objects that are going to be added, which it obtains by computing distance(first,last).

The same applies to "repeat n times" operations, such as the vector constructor that takes a repeat count and a value.

    Team LiB
    Previous Section Next Section