By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

hybrid of back_inserter and forward_iterator

P: n/a
I want sort of a hybrid between these two. I want an iterator where *
operator can both read from and write to elements in the collection,
intelligently calling push_back if necessary in order to write without
going out of bounds.

Is something like this possible? I have something I whipped together
that seems to work with the test cases I've given it, but I'm not 100%
confident that it's bulletproof since it's been quite some time since
I was heavily involved with STL. Can post it if necessary, but
chances are this has been tried before and I'll either get a "yes,
look here for code" or "no don't even bother".

Thanks

Jun 14 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2007-06-14 22:01, Zachary Turner wrote:
I want sort of a hybrid between these two. I want an iterator where *
operator can both read from and write to elements in the collection,
intelligently calling push_back if necessary in order to write without
going out of bounds.

Is something like this possible? I have something I whipped together
that seems to work with the test cases I've given it, but I'm not 100%
confident that it's bulletproof since it's been quite some time since
I was heavily involved with STL. Can post it if necessary, but
chances are this has been tried before and I'll either get a "yes,
look here for code" or "no don't even bother".
Depends a bit of what behaviour you expect from it, but if you want it
to always insert at the end (even if the iterator is not at the end)
then it should be fairly trivial (I think, I have not really looked into
it) if you keep a reference to the container in the iterator.

--
Erik Wikström
Jun 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.