Is there a difference in for( auto ) vs for( auto* )?

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 )

or like this:

for( auto* Tile : Tiles )

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);


	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.

In the first case, auto and auto* should behave the same. In the second case, it is different, if you don’t have the & it will make copies of each entry in the array instead of references.You’ll probably want to use references in most cases.

I just want to add to 's answer. In the first case the first element of an array will always be treated as a pointer to the array’s memory location. So the reason there is no difference in the first set of syntax is because the array is treated as a pointer.