I’m trying to return 2 values by reference through a TTuple. Each value is a TArray of a UStruct type. However I get the following error “No suitable conversion from std::decay<…> to <…>” I’m pretty new to C++ so wondering where the std::decay is factoring in (as this works fine using a single return value without the tuple.)
I guess TTuple do not support references (but maybe I’m wrong). Maybe you could try with pointers instead of references ?
Anyway, your code looks suspicious to me: by using references, the lines where you assign the array references to the “storage” value would overwrite completely the “playerinventory”. I am not sure this is the intent. Be careful, references have “value” semantics.
Haven’t used TTuple but I think you should do something like this:
TTuple<uint32, float> *my_tuple(){
test = TTuple<uint32, float>(128, 9.999); // test is init somewhere.
/*
current computation.
*/
return &test; // Return for other computations.
}
Oh sorry. Yes the test will be destroyed when the function my_tuple life span ends.
if your want this tuple to be valid out of the function, you might initialize it somewhere else. e.g., inside a class. Then you have initialization function. process function, and get function.
and the curr_search_point is init under ‘private’:
private:
const int *w;
const int *h;
// Point.
TMap<int, float> point_distance; // To dynamically hold current search point.
FVector2D curr_search_point;
Or you can do this as well.
Say your tuple will be used in func A and its value is calculated in func B.