Talk:cpp/container/list/insert

Return value seems incorrect
The page states that the return value is the "iterator following the last inserted element". However, my understanding is that the returned iterator should point to the first element inserted. Thus, the newly inserted elements occupy the range [ret_val, pos).

From §23.2.3 of the C++11 standard: The iterator returned from a.insert(p, t) points to the copy of t inserted into a. The iterator returned from a.insert(p, rv) points to the copy of rv inserted into a. The iterator returned from a.insert(p, n, t) points to the copy of the first element inserted into a, or p if n == 0. The iterator returned from a.insert(p, i, j) points to the copy of the first element inserted into a, or p if i == j. The iterator returned from a.insert(p, i1) points to the copy of the first element inserted into a, or p if i1 is empty.  Thanks. 130.20.187.25 14:49, 21 March 2012 (PDT)


 * good catch. Updating. --Cubbi 18:52, 21 March 2012 (PDT)

Complexity for list
The complexity of insert for lists in C++11 (per §23.3.5.4) is:

1-2) Constant.

3) Linear in

4) Linear in

5) Linear in

130.20.187.25 15:47, 21 March 2012 (PDT)