On 04/05/2017 at 08:42, xxxxxxxx wrote:
Hi gr4ph0s, first thanks for keeping asking.
With reference to your question, I suggest you to have a look inside the basearray.h at the BaseArray template definition. There you'll find a MAXON_DISALLOW_COPY_AND_ASSIGN preprocessor directive which basically prevents copying the class specified (in our case the BaseArray itself).
Because of this directive you're provided by the compiler with the C2248 error you've reported. Basically when you try to store a new instance of MyStructB into the ArrayOfIntArray pointed by myVar the directive prevents your instance to get copied and assigned to the appended entry of the ArrayOfIntArray.
In order to make everything working smoothly, you have to store pointers to MyStructB in the BaseArray in MyStructA and operate accordingly
struct MyStructB{
maxon::BaseArray<Int32> ArrayOfInt;
};
struct MyStructA{
maxon::BaseArray<MyStructB*> ArrayOfIntArray;
};
// auto-allocate an instance of MyStructA
AutoNew<MyStructA> arrStructB;
// check the pointer of the allocated instance
if (!arrStructB)
return;
// append an pointer going to point to a 'soon-to-be-allocated' MyStructB
arrStructB->ArrayOfIntArray.Append();
// allocate the MyStructB instance and save the memory location in the pointer
arrStructB->ArrayOfIntArray[0] = NewObjClear(MyStructB);
if (arrStructB->ArrayOfIntArray[0])
{
// fill the newly created instance of MyStructB
arrStructB->ArrayOfIntArray[0]->ArrayOfInt.Append(1);
arrStructB->ArrayOfIntArray[0]->ArrayOfInt.Append(10);
arrStructB->ArrayOfIntArray[0]->ArrayOfInt.Append(100);
}
// append another pointer going to be point to another MyStructB
arrStructB->ArrayOfIntArray.Append();
// allocate the MyStructB instance and save the memory location in the pointer
arrStructB->ArrayOfIntArray[1] = NewObjClear(MyStructB);
if (arrStructB->ArrayOfIntArray[1])
{
// fill the newly created instance of MyStructB
arrStructB->ArrayOfIntArray[1]->ArrayOfInt.Append(2);
arrStructB->ArrayOfIntArray[1]->ArrayOfInt.Append(20);
arrStructB->ArrayOfIntArray[1]->ArrayOfInt.Append(200);
}
// check that everything is properly stored
for (int i = 0; i < arrStructB->ArrayOfIntArray.GetCount(); ++i)
{
MyStructB* pMyStructB = arrStructB->ArrayOfIntArray[i];
for (int j = 0; j < pMyStructB->ArrayOfInt.GetCount(); ++j)
{
Int32 value = pMyStructB->ArrayOfInt[j];
GePrint("[" + String::IntToString(i) + "," + String::IntToString(j) + "]: " + String::IntToString(value));
}
}
// deallocate each instance pointed by the pointers stored in the MyStructA instance
for (int i = 0; i < arrStructB->ArrayOfIntArray.GetCount(); ++i)
{
DeleteObj(arrStructB->ArrayOfIntArray[i]);
}
Best, Riccardo