lundi 5 août 2019

Call Operator() for custom class std::shared_ptr instance

I have my own extended 2d-array class CustomDynamicArray which cover std::vector and allow handle its items by indexes via overloaded operator()

CustomCell& CustomDynamicArray::operator()(size_t colIdx, size_t rowIdx)

until I had simple CustomDynamicArray instance

CustomDynamicArray _field;

I might adressed to array items next way:

_field(x, y) = cell;

or

const CustomCell& currentCell = _field(x, y);

But since I covered my varrible into std::shared_ptr I have an error

std::shared_ptr<CustomDynamicArray> _fieldPtr;
_fieldPtr(x, y) = cell; // Error! C2064 term does not evaluate to a function taking 2 arguments
const CustomCell& currentCell = _fieldPtr(x, y); // Error! C2064    term does not evaluate to a function taking 2 arguments

How I should fix this compile error?

Aucun commentaire:

Enregistrer un commentaire