Pointers in UE_LOG()

From the 3rd person battery collector tutorial we’re told to log like this:


void ASpawnVolume::GetSpawnVolumeDetails()
{
	FVector SpawnOrigin = WhereToSpawn->Bounds.Origin;
	FVector SpawnExtent = WhereToSpawn->Bounds.BoxExtent;
	UE_LOG(LogTemp, Warning, TEXT("Origin: %s Extent: %s"), *SpawnOrigin.ToString(), *SpawnExtent.ToString());
}

What I don’t understand is that SpawnOrigin.ToString() and SpawnExtent.ToString() return FString. So why is it that I have to dereference them with a * when they’re not pointers?

Fstring is overriding the dereference operator to return the character array.

It is defined like this (UnrealString.h):



/**
 * Get pointer to the string
 *
 * @Return Pointer to Array of TCHAR if Num, otherwise the empty string
 */
FORCEINLINE const TCHAR* operator*() const
{
	return Data.Num() ? Data.GetData() : TEXT("");
}


HTH

Thank you, it’s been bugging me all week lol

Your welcome :slight_smile: