2018년 11월 6일 화요일

C++ - Configuring the Struct Operator "<<"

//Example Code;

USTRUCT(BlueprintType)
struct FMapInformation
{
GENERATED_USTRUCT_BODY()

public:
TEnumAsByte<ETileType::Type> TileType;

FVector TileLocation;

friend FArchive& operator << (FArchive& Ar, FMapInformation& OtherInfo)
{
Ar << OtherInfo.TileType << OtherInfo.TileLocation;

return Ar;
}
};


Must be specified as reference unconditionally!!

  • friend FArchive& operator << (FArchive& Ar, FMapInformation& OtherInfo)


Otherwise there will be problems.