hybrid of back_inserter and forward_iterator

Z

Zachary Turner

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
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top