|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-03-26 11:24:18
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 26 March 2008 11:08 am, Daniel Frey wrote:
> But shared_from_this() requires that there must exist at least one
> shared_ptr instance that owns the object, which means that the
> use_count() is always guaranteed to be >0, hence the exception is never
> thrown by shared_ptr's ctor.
The exception is thrown if the user violates the requirement. Actually, on
the svn trunk the requirement is looser, shared_from_this can be called
before a shared_ptr has taken ownership (the docs haven't been updated to
reflect that though). It's still possible to throw though, if the object
outlives the shared_ptrs that own it.
> Oh, and the ctor of shared_ptr therefore *can* throw something else than
> std::bad_alloc, right?
Yes, and it says so in the constructor's documentation. I'm not familiar with
the precise rules of C++ language specification-ese, so I don't know if the
blanket statement about the classes' "functions" in the intro also applies to
constructors?
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFH6mqi5vihyNWuA4URAvuhAKDRAlY6DMuwkB7C2Toq1VKxdiKWvwCfake0
IMG6Vdh17iadvwY3Rt18KFs=
=REta
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk