Christopher Pisz wrote:
Is there a way to build a seperate array of objects, when those
objects are members of other objects, which are contained in a STL
data structure? , without iterating through the whole list one by one
and getting them seperatlely.
class A
{
public:
int * m_data;
};
typdef list<AMyList;
MyList g_mylist;
void Foo()
{
// for each A object I need the data member
int ** datalist = ??
}
No, there is no way to do that without iterating through the whole
list. However, you could avoid iterating yourself if you write
a particular _functor_ and then use 'std::for_each'. Of course it
only means you're hiding the actual iteration behind the call to
'for_each' (and internally it does iterate through the range of
iterators you pass in), but it might be what you're asking about.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask