Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-03-06 18:06:36


Scott Meyers wrote:
> Consider this constructor from the intrusive_ptr doc
> (http://boost.org/libs/smart_ptr/intrusive_ptr.html):
>
> intrusive_ptr(T * p, bool add_ref = true);
>
> Effects: if(p != 0 && add_ref) intrusive_ptr_add_ref(p);.
>
> Note in particular that nothing is said about exceptions being thrown.
> Presumably intrusive_ptr_add_ref may throw, as I can't find any
> restriction to the contrary.
>
> Now consider these constructors from the same document:
>
> intrusive_ptr(intrusive_ptr const & r); // never throws
> template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r); // never
> throws
>
> Effects: if(r.get() != 0) intrusive_ptr_add_ref(r.get());.
>
> They are documented not to throw, yet both call
> intrusive_ptr_add_ref. How can it be that the top constructor above
> may throw, but these constructors may not?

You are right, this is a documentation bug (similarly for operator=). The
"// never throws" annotations aren't present in the synopsis. Fixed in CVS,
thanks for the report.


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