473,405 Members | 2,334 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,405 software developers and data experts.

Can I use back_inserter as the output iterator?


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* operator()(string& str)
{
return new Astr);
}
};

void buildAVector( vector<string>& inputs, vector<A*>& aList) {

// this does not comile
transform(inputs.begin(), inputs.end(), back_inserter(aList.begin()),
build());

// this does:
transform(inputs.begin(), inputs.end(), aList.begin(), build());
}

Feb 16 '06 #1
1 2402
Al************@gmail.com wrote:
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* operator()(string& str)
{
return new Astr);
}
};

void buildAVector( vector<string>& inputs, vector<A*>& aList) {

// this does not comile
transform(inputs.begin(), inputs.end(), back_inserter(aList.begin()),
Change to

.... back_inserter(aList),
build());

// this does:
transform(inputs.begin(), inputs.end(), aList.begin(), build());
}


V
--
Please remove capital As from my address when replying by mail
Feb 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Anders | last post by:
Hello there. Can anyone tell me why the ++-operator is defined for ostream_iterator ? I can't see the difference between: ostream_iterator<int> test(cout); test++ = 1; test++ = 2; test++ =...
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: >>>...
6
by: Anirudh Ramachandran | last post by:
Hi all, I have a homework problem here, where I have to perform a set intersection on two sets and use the result elsewhere. I have this code: #include <iostream> #include <iterator>...
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...
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...
1
by: Zachary Turner | last post by:
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...
8
by: Bo Yang | last post by:
Hi, Today, I make some test on the C++ STL iterators of set containers with GNU g++ compiler. The code is: #include <set> #include <iostream> using namespace std; int main(int argc, char...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.