, __pEnum(__pList->GetBidirectionalEnumeratorN())
, __currentObj(null)
{
- if (!isPostEnd)
+ if (__pList->GetCount() != 0)
{
- __pEnum->MoveNext();
- __currentObj = static_cast< T >(__pEnum->GetCurrent());
+ if (!__isPostEnd)
+ {
+ __pEnum->MoveNext();
+ __currentObj = static_cast< T >(__pEnum->GetCurrent());
+ }
+ else
+ {
+ __index = __pList->GetCount();
+ __pEnum->MovePrevious();
+ }
}
else
{
- __index = __pList->GetCount();
- __pEnum->MovePrevious();
+ // Control reaches here intentionally because begin() should be equal to end()
+ __isPostEnd = true;
}
}
, __pEnum(__pMap->GetMapEnumeratorN())
, __currentObj()
{
- if (!isPostEnd)
+ if (__pMap->GetCount() != 0)
{
- __pEnum->MoveNext();
- __currentObj.first = static_cast< K >(__pEnum->GetKey());
- __currentObj.second = static_cast< V >(__pEnum->GetValue());
+ if (!__isPostEnd)
+ {
+ __pEnum->MoveNext();
+ __currentObj.first = static_cast< K >(__pEnum->GetKey());
+ __currentObj.second = static_cast< V >(__pEnum->GetValue());
+ }
+ else
+ {
+ __index = __pMap->GetCount();
+ }
}
else
{
- __index = __pMap->GetCount();
+ // Control reaches here intentionally because begin() should be equal to end()
+ __isPostEnd = true;
}
}
, __pEnum(__pMultiMap->GetMapEnumeratorN())
, __currentObj()
{
- if (!__isPostEnd)
+ if (__pMultiMap->GetCount() != 0)
{
- __pEnum->MoveNext();
- __currentObj.first = static_cast< K >(__pEnum->GetKey());
- __currentObj.second = static_cast< V >(__pEnum->GetValue());
+ if (!__isPostEnd)
+ {
+ __pEnum->MoveNext();
+ __currentObj.first = static_cast< K >(__pEnum->GetKey());
+ __currentObj.second = static_cast< V >(__pEnum->GetValue());
+ }
+ else
+ {
+ __index = __pMultiMap->GetCount();
+ }
}
else
{
- __index = __pMultiMap->GetCount();
+ // Control reaches here intentionally because begin() should be equal to end()
+ __isPostEnd = true;
}
}