While there exists an equivalent of boost::shared_ptr
(QSharedPointer
) I wasn't able to find something that resembles boost::shared_array
.
Of course I could use something similar to
QSharedPointer<const std::vector<T> > shared_vector_ptr(new std::vector<T>(
reinterpret_cast<T*>(pBuffer),
reinterpret_cast<T*>(pBuffer+length)
));
but I would like to know if there exists a native Qt solution which provides T& operator[](size_t)
and uses delete[]
instead of delete
. I'm reluctant to use boost in this project since the target machine couldn't have boost installed and the project gets distributed by source.
Note: I know I can specify a deleter by using QSharedPointer::QSharedPointer ( T * ptr, Deleter deleter )
, however I dislike approach since the compiler doesn't force you to specify a deleter, which would result in a new []
allocated block deleted by delete
.