Hi, I want to use Array_Find function in C++, so how i can overload the missing operator?
I know it will need to rebuild the engine, so i have no other choice , i am ready to rebuild the engine so please help me
example:
Index = FCustomThunkTemplates::Array_Find(TransformArray, Location);
bEqualValid = UKismetMathLibrary::EqualEqual_IntInt(Index, -1);
ERROR::
binary â==â: no operator found which takes a left-hand operand of type âconst FTransformâ (or there is no acceptable conversion) Containers\Array.h
Still trying to fit an âintâ into an âF transformâ, I see.
If I were you I would return a float above directly in the return statement.
Itâs the last line giving the error Location is an Ftransform type and you are trying to store it to Index that is an int. There is no engine error, you want to modify the engine so a int accepts a ftransform. Counting itâs a template type and you want to store the tepmlate to int.
I donât know what is behind this
FCustomThunkTemplates::Array_Find
It might be that this makes a conversion possible, but I doubt it.
Itâs a strange for loop, I never seen it like this. " but you can tell that itâs counting with ++Data"
Itâs counting the variable Data and as in counts if it encounters something identical like in the Item it returns a static_cast, or as I see at the end a range between Data and Start. There is no conversion elements here.
I donât think there is anything wrong with this, your addition is wrong that you are trying to store it to int.
Dont use Array_Find it works behind the scene on memory level for registered products instances, you can do it manually but it will have a huge risk of memory leak, I recommend to use ContainsByPredicate using do|while loop , but you can overload == and != for int = transfromArrayElements.find(TransformElement)
Sir I donât store it to int, I find the Ftransform data in Ftransform Array variable and then during this search of data between them I am sure there is an index which I am storing in int
This find function is returning an integer
Well the error is clear, it refers to conversions from one type to other type.
no operator found which takes a left-hand operand of type âconst FTransformâ
1
So itâs a type FTransform that you are fiting inside âIndexâ
This is the actual error and because of this you got an error with type Ftransform.
2
You are putting an FTransform as a parameter on a function call and maybe that function does not contain an Ftransform there for you are trying to convert a parameter to Ftransfrom
Itâs either one or two, or maybe bolth.
Tell me here, where do you see an Ftransfrom type here
SizeType Find(const ElementType& Item) const
{
const ElementType* RESTRICT Start = GetData();
for (const ElementType* RESTRICT Data = Start, *RESTRICT DataEnd = Data + ArrayNum; Data != DataEnd; ++Data)
{
if (*Data == Item)
{
return static_cast<SizeType>(Data - Start);
}
}
return INDEX_NONE;
}```
The types here are not of Ftrasnfrom ? nor floats ?
Yet you put an Ftransform as a type inside the parameter of the function call.
Fist you need to have a condition setter the loop will follow when to stop and continue.
lets take a bool value false/true.
myclass.cpp
do
{
SpawnLocation = Location;
UsedLocations.Add(SpawnLocation);
break;
}
while (UsedLocations.ContainsByPredicate([Location](const FTransform Transform)
{
return Transform.GetLocation() == Location.GetLocation();
}));
RandomLocation(Available, Location); //do this if the locations are not unique