Re: [std-proposals] new std::vector::insert

52 views
Skip to first unread message

David Rodríguez Ibeas

unread,
Feb 18, 2015, 2:36:31 PM2/18/15
to std-pr...@isocpp.org
I am not following the ranges proposals, but this is something I would hope to be handled there. Basically the same solution that one of the answers provides in the form of transform_iterator, except that it would come with standard blessings.

I am not familiar with transform_iterator, but if it maintains the category of the underlying iterators (in particular, given a random access iterator, the adapted transform_iterator is also a random access iterator --and I don't see any reason why this would not be the case), that will be as efficient as can be (assuming a good implementation, it has enough information to reserve the space upfront and move/copy every object only once into the final location).

I don't think the addition of that additional insert overload would help.

     David

On Tue Feb 17 2015 at 12:22:21 PM Daniel Cooke <dan.c...@gmail.com> wrote:
I think it would be useful, from a user perspective, but also potentially from a performance perspective, to allow for a unary operator parameter in std::vector::insert. I have recently posed two questions on SO addressing this issue (see here, and here).

The form of the function should be:

template <class InputIterator, class UnaryOperation>
iterator insert (const_iterator position, InputIterator first, InputIterator last, UnaryOperation op);

While it is not clear to me if this would have any significant performance advantage over the methods discussed on SO, it would in-any-case remove uncertainty of cost.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
Reply all
Reply to author
Forward
0 new messages