In Unreal Engine, I've created a series of structs in C++ that let me generate a replicated version of the TMap struct. It relies on a number of engine resources like Fast Array Serialization, and the structs needs to be recognized by the engine like a normal USTRUCT.
For example, here's there starting piece of one of the structs:
USTRUCT(BlueprintType)
struct FReplicatedTMap_GuidToGuid_Array : public FFastArraySerializer
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, NotReplicated, VisibleAnywhere)
TMap<FGuid, FGuid> ReplicatedMap;
Long story short, my implementation works. However, due to UHT (Unreal Header Tool) constraints, I cannot use templates
USTRUCT(BlueprintType)
template<>
because it isn't supported by the engine, and I can't use macros
#define \
USTRUCT(BlueprintType) \
because the UHT pre-processor doesn't expand macros before looking for its own macros like USTRUCT(), and this prevents pre-processor generated code from being evaluated by the engine.
In the first code example, you can see that each set of struct/function definitions only apply to one key type - value type pair. The code itself is only ~150 lines or so, but I'd like to not have to change multiple dozens of definitions every time I need to tweak these struct templates, let alone create additional copies whenever I need new types.
Is there a solution within Unreal, or using C++? What's the best way to autogenerate the code I need?