boost::shared_ptr
(QSharedPointer
)과 동일한 항목이 있지만 boost::shared_array
과 비슷한 것을 찾을 수 없습니다. 내가Qt 스마트 포인터가 boost :: shared_array에 해당하는가요?
QSharedPointer<const std::vector<T> > shared_vector_ptr(new std::vector<T>(
reinterpret_cast<T*>(pBuffer),
reinterpret_cast<T*>(pBuffer+length)
));
에 비슷한 사용할 수 있지만 T& operator[](size_t)
을 제공하고 대신 delete
의 delete[]
를 사용하는 기본 Qt는 솔루션이 존재한다면 내가 알고 싶습니다 물론
. 대상 컴퓨터가 설치되어 있지 않고 프로젝트가 소스별로 배포되기 때문에이 프로젝트에서 부스트를 사용하기를 꺼립니다.
참고 : 나는 컴파일러가 delete
에 의해 삭제 new []
할당 된 블록을 초래할 것 Deleter가를 지정하도록 강요하지 않기 때문에 그러나 나는 접근 방식을 싫어, 내가 QSharedPointer::QSharedPointer (T * ptr, Deleter deleter)
을 사용하여 Deleter가 지정할 수 있습니다 알고 있습니다.
주제에 대한 두 가지 뛰어난 게시물이 있습니다. http://stackoverflow.com/questions/5026197/what-c-smart-pointer-implementations-are-available 및 http://stackoverflow.com/questions/7875764/ using-qsharedpointer-new-yields-mismatched-free-delete-delete-i – KCiebiera
참조 용으로 추가 downvotes 자신을 설명 할 수 있을까? 나는 downvotes에 아무런 문제가 없지만, 당신이 잘못한 것을 배우기는 어렵다. – Zeta