I'm facing the following problem:
I want to pass the _partHandlePtr to the constructor of _currUnmanaged and _extUnmanaged but getting errors like "memory access violation occurred at address 0x00000010, while attempting to read inaccessible data". I also tried to initialize both instances after 2) but the problem is that I can't use the assignment operator on them. So is there another option to initialize _currUnmanaged and _extUnmanaged without using list initialization or is the problem elsewhere?
class DerivedCollect {
DerivedCollect(
const IGCollect& inputCollect,
Handle handle) :
_partHandlePtr(nullptr),
_currUnmanaged(_partHandlePtr),
_extUnmanaged(_partHandlePtr)
{
// 1) Filling _pHandles
_pHandles.push_back(HandleManager::GetPHandle(handle));
for (const auto& it : inputCollect.GetPartHandles())
{
_pHandles.emplace_back(it);
}
// 2) Make _partHandlePtr referencing to _pHandles
_partHandlePtr = std::make_shared<std::vector<Handle>>(_pHandles);
}
private:
std::shared_ptr<std::vector<Handle>> _partHandlePtr;
std::vector<Handle> _pHandles;
UnmanagedCollect _currUnmanaged;
UnmanagedCollect _extUnmanaged;
}
class UnmanagedCollect {
UnmanagedCollect(
std::shared_ptr<std::vector<Handle>> partHandlePtr) :
_partHandlePtr(partHandlePtr)
{
}
private:
std::shared_ptr<std::vector<Handle>> _partHandlePtr;
}
Thanks for suggestions and solutions!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…