
13 Jul
2007
13 Jul
'07
9:02 a.m.
hongleij@126.com wrote: [...]
/// why boost::shared_ptr can used to Minimize compilation dependencies between files, yet boost::scoped_ptr cannot. I needn't to use reference cout.may someboby help me out of the trouble.thanks!
scoped_ptr can be used like you want. From the smart_ptr documentation: 'Note that scoped_ptr requires that T be a complete type at destruction time, but shared_ptr does not.' IOW, you need to define a possible empty destructor of your class in a source file, and only there the complete type of T must be available. See the example referenced in http://boost.org/libs/smart_ptr/scoped_ptr.htm, section 'Handle/Body Idiom'. HTH, Markus