A
Allerdyce.John
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());
}
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());
}