Use range loops without hiding useful types
A const reference avoids copying each pair and keeps the key and value types visible.
for (const TPair<FGameplayTag, int32>& Stack : StackCounts)
{
if (Stack.Value <= 0)
{
continue;
}
UE_LOG(
LogInventory,
Verbose,
TEXT("%s: %d"),
*Stack.Key.ToString(),
Stack.Value);
}- Why
- The loop cannot modify the map. The explicit type also remains clear in a diff or code review where IDE type hints are unavailable.
- Costs
- Some iterator and template types are unreadably long. Epic permits
autofor those cases and for lambdas. - Instead
- Use
Algofunctions when a named operation such asSort,Transform, orFindByPredicatesays more than the loop mechanics.

