$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: bringiton bringiton (kneeride_at_[hidden])
Date: 2006-07-16 11:55:48
>>You can do reset() in the constructor of the wrapper (or was it
just an example?)
yes just an example. however that is how i have it at the moment.
i was thinking about doing allocation in the constructor, but this
opens too much confusion because it would be unclear via the interface
whether the default contructor would 1. allocate a null/empty
shared_ptr, or 2. allocate a default object. ie
Ptr<Test> p(1, 'a', "hello"); // OK, object created
Ptr<Test> p2; // ??? unclear if default object allocated or null pointer
I think the best way around this would be to have a static function
create a pointer and treat the declaration with initialisation syntax.
eg
Ptr<Test> p; // null object
Ptr<Test> p2 = Ptr<Test>::New(); // default object allocated
Ptr<Test> p3 = Ptr<Test>::New(1, 'a', "hello"); // object allocated
What are your thoughts Evgeniy?
i'm hoping the compiler would be able to optimise the above. ie use
copy constructor instead of default constructor + operator=(). maybe
even realise that only 1 object needs to be created. **but i dont know
much about this area