Re: [Boost-users] Macro to contruct/allocate a shared_ptr?
14 Jul
2006
14 Jul
'06
11:13 a.m.
Thanks Roman.
so is this how i would use your implementation?
boost::shared_ptr<Test> t = newptr
(1, 'a', "hello"); that is getting a lot closer to what i need. and is far better that a MACRO. declaring the types may annoying however.
the good thing about this approach it that is will also be exception safe: ie i dont need to declare a variable for the shared_ptr. and will be cleaned up if g() fails
// exception safe fn(newptr
(1, 'a', "hello"), g());
You can omit all but the first template parameters because they can be deduced by compiler. shared_ptr<Test> t = newptr<Test>(1, 'a', "hello"); which is equivalent to shared_ptr<Test> t = shared_ptr<Test>(new Test(1, 'a', "hello")); HTH, Roman Perepelitsa.
6698
Age (days ago)
6698
Last active (days ago)
0 comments
1 participants
participants (1)
-
Perepelitsa Roman