If I’m storing a list of tiles like so:
TArray<ATile*> Tiles;
and want to loop through them. The compiler doesn’t seem to care if I do it like this:
for( auto Tile : Tiles )
Tile->DoSomething();
or like this:
for( auto* Tile : Tiles )
Tile->DoSomething();
My question is, if I forget to do a * is it still treating it as a pointer?
My question is also the same when I’m looping through an array of structures that was passed in by reference like so:
void AGrid::InitiateMatches(const TArray<FGridMatch>& Matches )
Is there a difference if I do it like this:
for (auto Match : Matches)
InitiateMatch(Match, SwappedA, SwappedB);
vs:
for (auto& Match : Matches)
InitiateMatch(Match, SwappedA, SwappedB);
My goal in the above example is to make sure I’m not doing any sort of unnecessary copying.