Boost logo

Boost :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-09 14:18:28


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 09 April 2008 14:13 pm, Daniel Frey wrote:
> On Wed, 2008-04-09 at 13:40 -0400, Frank Mori Hess wrote:
> > But *this inside enable_shared_from_this<T> is not a T*, it is a
> > enable_shared_from_this<T>*. To downcast it to a T* requires a
> > dynamic_cast for the general case, which requires a vtable. Not that I
> > consider a vtable to be significant overhead (I know, it's a horrifiying
> > opinion for a C++ programmer but there it is).
>
> static_cast<T*>(this) should be legal AFAIK (and doesn't need a vtable)

It works in some cases, but it will fail the
smart_ptr/test/shared_from_this_test.cpp test for example.

- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH/Qh15vihyNWuA4URAoanAKDl0x7Gg7kLDonOZtds/xeIG/eBngCgtP7Z
+fVQ6X5wP/WT7JRyAnSJtf8=
=m0wT
-----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