C2511 .gen.cpp UnrealHeaderTool generating wrong function code?

Hi there,

I made a function and can’t compile it, since I get the error message C2511 “overloaded member function not found in ‘class’”.
Here are the .h .cpp and .gen.cpp lines of code:

.h


 UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
bool UpdateInstanceData(TEnumAsByte<EBlockTypes> BlockType, UHierarchicalInstancedStaticMeshComponent* InstanceComponent, TMap<FVector, int32> InstanceIndexMap);

.cpp


bool UpdateInstanceData(TEnumAsByte<EBlockTypes> BlockType, UHierarchicalInstancedStaticMeshComponent* InstanceComponent, TMap<FVector, int32> InstanceIndexMap)

.gen.cpp (generated by UnrealHeaderTool)


bool AWorldInstanceTerrainActor::UpdateInstanceData(EBlockTypes BlockType, UHierarchicalInstancedStaticMeshComponent* InstanceComponent, const TMap<FVector,int32>& InstanceIndexMap)

As you can see, the UnrealHeaderTool seems to generate code, that is different from my function declaration.
The Enum is “EBlockTypes BlockType” instead of TEnumAsByte<EBlockTypes> BlockType, and the .gen.cpp puts a “&InstanceIndexMap” instead of “InstanceIndexMap”.
I have absolutely no idea why (I am a c++ rookie) and similar stuff that can be found via google is too different from my case. So I can’t transfer it to this issue.
Does someone know whats going on?

Thanks i advance. :frowning:

Codi

TEnumAsByte isn’t exposed to Blueprints and should only really be used for C++ variables. Just use the “normal” enum ‘EBlockTypes’ in your function, you can use TEnumAsByte::GetValue to convert to the raw enum and back to a byte.

1 Like

Hey ExtraLifeMatt, thank you for the clarification. That’s the reason why it generates the ‘EBlockTypes’ I suppose?
And do you have an idea, why it generates the

const TMap<FVector,int32>& InstanceIndexMap’ instead of

‘TMap<FVector, int32> InstanceIndexMap’ ?

Thanks again. :slight_smile:

Probably because you shouldn’t pass a TMap by value as it would copy the entire TMap over, so instead you should use a const reference when you want to pass it as read-only.

hey brunocoimbra, thanks for you answer. First of all, now it seems to work.

But to get this straight… I thought passing the parameter with “&” means passing as ‘reference’. So my TMap (class variable) is altered inside of the function. Which is exactly what I want to do, but I read, that ‘&’ means that unreal will interpret this as a Blueprint return value. Or am I mixing things up here?
And what does ‘const’ mean in this context? I read http://duramecho.com/ComputerInforma…wCppConst.html

What does this mean? I want it to be altered, don’t I? :eek:

Sorry, this might be super nooby.