S
shaun
I have the following loop (names changed to protect the innocent):
for(MyContainer::const_iterator i=instance.begin();i !=
instance.end();++i)
{
hisContainerInstance.add(i->name());
}
so I am adding the names in the instance of MyContainer to hisContainer
instance, essentially a push_back operation.
Question: Can this be implemented as a for-each loop?
I can get as far as calling a member function of MyClass in the for-each:
for_each(instance.begin(),instance.end(),mem_fun_ref(&MyContainer::name))
but then can I call a function recurrently on *that* result?
e.g I'd like to:
for_each(instance.begin(),instance.end(),
hisContainerInstance.add(mem_fun_ref(&MyContainer::name)))
cheers
shaun
for(MyContainer::const_iterator i=instance.begin();i !=
instance.end();++i)
{
hisContainerInstance.add(i->name());
}
so I am adding the names in the instance of MyContainer to hisContainer
instance, essentially a push_back operation.
Question: Can this be implemented as a for-each loop?
I can get as far as calling a member function of MyClass in the for-each:
for_each(instance.begin(),instance.end(),mem_fun_ref(&MyContainer::name))
but then can I call a function recurrently on *that* result?
e.g I'd like to:
for_each(instance.begin(),instance.end(),
hisContainerInstance.add(mem_fun_ref(&MyContainer::name)))
cheers
shaun