I'd like to create a short lived list, over the life of a function, to collect a list of CPoint
objects and then iterate over those objects. I'd like to use CTypedPtrList
but I am not sure how to set it up to have it accept objects not derived from CObject
; CPoint
comes from a struct tagPOINT
.
Is it possible to use CTypedPtrList
with CPoint
?
Otherwise, should I just use std::list<CPoint>
? // I have started to use std:list
and can successfully build a list, but I cannot find a way to iterate over the list.
std::list<CPoint*> pointList;
// Add to the list with list.push_front(new CPoint(x, y));
std::for_each(pointList.begin(), pointList.end(), [](pointList* cur)
{
TRACE("APoint: %f, %f\n", cur->x, cur->y);
});
I have tried that, but I keep getting told that for_each
is not a member of std
. I tried to add #include <for_each>
(as I had to do for list
) but it still is not recognized.
Any suggestions?