RJM
(RJM)
August 29, 2016, 1:34am
1
new to C++, learning as i go.
i’ve tried a couple things but right now i have this.
USTRUCT(BlueprintType)
struct FMyStruct
{
GENERATED_BODY()
UPROPERTY(BlueprintReadOnly, EditAnywhere)
TArray<int32> dllVar;
FMyStruct()
{
TArray<uint32> t;
t = dllNamespace::dllStruct().dllVar.data; (this is a std::vector<uint32>)
//dllVar = (int32)t;
dllVar = int32(t);
}
};
the errors i get is no suitable conversion function from TArray to “int32” exists
any help or sending me in the right direction would help. Thank You
To answer your question: iterate over std::vector
and add every element to the new TArray
, like this
TArray<int32> TestTArray;
std::vector<int32> TestVector;
for (int32 element: TestVector)
{
TestTArray.Add(element);
}
Remarks:
1 . In this line
dllVar = int32(t);
you are trying to assign value int32(t)
of type int32
to a variable dllVar
of type TArray
and there is neither implicit nor explicit conversion between int32
and TArray
2 . also in that line you are trying to convert t
of type TArray
(or is it std::vector
) to a value of type int32
3 . What is dllNamespace::dllStruct().dllVar.data
?
RJM
(RJM)
August 29, 2016, 3:02pm
3
cant use <> when using bold or code sample, so using parentheses
hey thank you for responding. i tried updating my title to specifically say convert from std::vector(uint32_t) to TArray(int32)
i’m trying to assign what i hoped was a TArray(int32) to dllVar .
i thought typecasting t , which is a TArray(uint32) , from the std:vector(uint32_t) would work.
dllNamespace::dllStruct().dllVar is a DLL struct i’m calling
dllNamespace::dllStruct().dllVar.data i assumed was std::vector::data