Linked by Thom Holwerda on Mon 24th Aug 2009 15:06 UTC, submitted by diegocg
Qt Qt usually takes the boring memory allocation and deallocation from you, either through its implicitly shared containers, or with QObject's parent child relationship model. But every once in a while, we need to allocate something on the heap, and then the stress starts - where do we delete it, and how do we make sure to not leak the memory? To fix this problem, QScopedPointer was born. It will delete the object it is pointing to automatically when it goes out of scope.
Thread beginning with comment 380357
To read all comments associated with this story, please click here.
Duplicated effort?
by Chicken Blood on Mon 24th Aug 2009 18:41 UTC
Chicken Blood
Member since:
2005-12-21

It looks to me like std::shared_ptr in the boost library does the same job. This is due to appear as a part of the standard in C++ 00x.

OTOH, I'm not sure there is a simple way to make std::shared_ptr give up ownership of an object.

RE: Duplicated effort?
by vivainio on Mon 24th Aug 2009 18:47 in reply to "Duplicated effort?"
vivainio Member since:
2008-12-26

No, it's auto_ptr / auto_array.

Reply Parent Bookmark Score: 3

RE: Duplicated effort?
by adkilla on Tue 25th Aug 2009 07:10 in reply to "Duplicated effort?"
adkilla Member since:
2005-07-07

This is mainly to provide better support for Qt on platforms like Symbian that would not have TR1/C++0x class library support.

Boost has an ugly API and you can't dissect and pick one portion of the library separately to use. You have to include the whole Boost library as it is interdependent within itself.

Reply Parent Bookmark Score: 2

RE[2]: Duplicated effort?
by tramo on Tue 25th Aug 2009 08:03 in reply to "RE: Duplicated effort?"
tramo Member since:
2009-08-25

It's *extremely* easy to cherry pick different parts of Boost and include them in your project. That's what 'bcp' is for, and it works like a charm. Yes, it will pull in a lot of headers (partly because boost shares a lot of things, and otherwise because 'bcp' is conservative about what it includes), but the actual *code* it pulls in is minimal. Try doing this with another general purpose library (not even talking about the horrible Qt, which *does* pull in a lot of crap; now *that's* a heavy dependency).

Boost has a horrible implementation (the price you pay for performance), but boost APIs are always very minimal. (what API is there to shared pointers anyway?) And who cares about ugly implementations if they are well tested and work?

Reply Parent Bookmark Score: 1

RE[2]: Duplicated effort?
by FooBarWidget on Thu 27th Aug 2009 16:56 in reply to "RE: Duplicated effort?"
FooBarWidget Member since:
2005-11-11

You definitely can cherry-pick parts. That's exactly what, for example, Phusion Passenger does.

Edited 2009-08-27 16:57 UTC

Reply Parent Bookmark Score: 2