ATL collection classes did not receive an update related to new C++11 range-based for
s and other fancy features. Well it’s a pity because writing
for(auto&& pPin: AudioPinList)
pPin-> //...
compared to
for(POSITION Position = AudioPinList.GetHeadPosition(); Position; AudioPinList.GetNext(Position))
{
IPin* pPin = AudioPinList.GetAt(Position);
pPin-> //...
is indeed a relief. Namespace std
is, of course, good but ATL is still here as well. Here is a take on adding range-based for loops to ATL collection classes.
CRoIterativeCollectionT
class is a traits-based uniform base for lists and arrays, adding (again, uniform) helpers to iterate through collection:GetCountThat
,GetThat
,RemoveThat
,RemoveFirst
,RemoveLast
Find
,FindThat
,FindFirst
,FindLast
,FindFirstThat
,FindLastThat
ForEach
begin
,end
implementing for range based for loops
CRoArrayT
is a class extendingCAtlArray
, adding mentioned above through inheriting fromCRoIterativeCollectionT
CRoListT
is a class extendingCAtlList
, adding mentioned above through inheriting fromCRoIterativeCollectionT
CRoAssignableListT
,CRoAssignableArrayT
,CRoAssignableMapT
to inherit collections and allow assignment operators on those (through duplication of elements), esp. to be able to easily put the collections as members of classes, eligible for assignment operator copiesCRoFixedArrayT
,CRoFixedMapT
are compatible collection classes backed by stack memory only, no allocations (old stuff as is, was used somewhere in handler where immediate response assumed no memory allocation operations)CRoMapT
is essentially an thin extension ofCAtlMap
, however also addsGetPositions()
andGetValues()
methods, which can be used for range-based for loops
Download
- Header file: roatlcollections.h