How to add function to struct in blueprint

Hi everyone
We know that struct in C++ can contains function like:

struct MyStruct {
    float a;
    float b;
 
    float add() {
        return a + b;
    }
}

I want to achieve it in pure blueprint, but it seems that blueprint struct only contains variable, and can not creat and edit function.
Is that true? If I want to create a function that only can be used by this struct (such as *MyStruct * above), how to do?

In this case you supposed to define functions in another “blueprint functions library” class, as statics with MyStruct as param. Not sure about exact rules, but being first param and const ref is surely works

So, i’d write your example in following way:

#include "Kismet/BlueprintFunctionLibrary.h"

USTRUCT()
struct FMyStruct 
{
	GENERATED_BODY()

	UPROPERTY(BlueprintReadWrite)
	float a;
	UPROPERTY(BlueprintReadWrite)
	float b;
 
	float Add() const {
		return a + b;
	}
}

UCLASS()
class UMyStructStatics : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, DisplayName = "Add")
	static UPARAM(DisplayName="Result") float BP_Add(const FMyStruct& MyStruct)
	{
		//you may write the implementation directly here, but i think it's better to keep it in native struct so they still can be easily used in native code
		return MyStruct.Add();
	};

}

This way you’ll be able to select Add function from the drop down list as if it was an FMyStruct’s function