Boost logo

Boost Users :

From: Evgeniy Zolenko (zolenkoe_at_[hidden])
Date: 2006-07-15 22:16:08


bringiton> Initially my shared pointers that encapsulated memory managent could
bringiton> only use the default contructor of T. ie:

bringiton> template <class T>
bringiton> class Ptr {
bringiton> void Allocate() {
bringiton> ptr.reset(new T());
bringiton> }

Ah, I see. So in your other code, where you need the pointer to a
class you manage, you accept a specialized wrapper of this class?

That is you, always pass pointers around like that:

void SetTestPointer(Ptr<Test> test);

And not unwrapped shared_ptrs for example.

PS
You can do reset() in the constructor of the wrapper (or was it
just an example?) Like that you separate allocation from
initialization, and that is just more work for users (unless you need
it for some reason).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net