SaveLoad TUnion

Hi,

I have struct with TUnion:

struct ItemAttribute {
    	TUnion<int, float> Value;
    };

And overload of operator<<

FORCEINLINE FArchive& operator<< (FArchive& Ar, ItemAttribute& wi) {
        	TArray<uint8> attrsToSave = {
        		0, // Attribute Value
        	};
        
        	Ar << attrsToSave;
        	for(uint8 attrID : attrsToSave) {
        		switch(attrID) {
        		case 0:
        			Ar << wi.Value;
        			break;
        		}
        	}
        
        	return Ar;
        }

When i try to compile project I get this error:

Error C2679 binary '<<': no operator found which takes a right-hand operand of type 'FNull' (or there is no acceptable conversion)

If I replace TUnion<int, float> Value; with TUnion<int, float, double, FString, FVector, FText> Value; then everythings works fine. But I don’t need more than two variables now.

Hi,

This was a bug that was fixed recently and should be available in 4.18. However, you can make the fix to your own copy of the engine by merging the change from here:

https://github.com/EpicGames/UnrealEngine/pull/3676

Sorry for the trouble,

Steve