473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

hybrid of back_inserter and forward_iterator

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
1 1356
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Markus Seibold | last post by:
Dear NG, I am working on a student project about a mobile tourism information system and among others I have to answer the question whether to use: - a relational database - a XML-native database...
8
by: Mark A. Gibbs | last post by:
I have a string conversion function that looks something like this (apologies, but I cannot post the actual code): whar_t char_to_wchar(char); wstring to_wstring(const string& s) { wstring...
2
by: Joe Laughlin | last post by:
Joe Laughlin wrote: > Mike Wahler wrote: >> "Joe Laughlin" <Joseph.V.Laughlin@boeing.com> wrote in >> message news:I60Dvs.FqL@news.boeing.com... <snip> >>> Joe Laughlin wrote: >>>...
3
by: silverburgh.meryl | last post by:
i have the following code, but it does not compile because I pass in back_inserter(b) as the output iterator in the remove_copy_if algorithm. My questions are: 1. why it does not compile? Passing...
1
by: Allerdyce.John | last post by:
Can I use back_inserter as the output iterator? The following code wont't compile, is there a reason for that? How can I achieve what I want? (grow aList if needed) class build { public: A*...
6
by: Daniel T. | last post by:
The line marked (1) below compiles fine and does exactly what I would expect, but the line marked (2) does not compile at all on my system. error: variable or field 'bar' declared void My...
17
by: Jess | last post by:
Hello, The iterator adaptor "back_inserter" takes a container and returns a iterator so that we can insert elements to the end of the container. Out of curiosity, I tried to look at what element...
0
by: johnsmith3853 | last post by:
Hey Guys, I am still in a thinking stage and will like to learn from your experience, and was wondering if any of you folks have a hybrid environment i.e. Linux and Proprietary systems and what kind...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.