Boost logo

Boost :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-11 16:43:00


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

On Friday 11 April 2008 15:00 pm, Fernando Cacciola wrote:
> Hi Thorsten,
>
> Adding the new requirement is out of the question, but it's definitely
> possible to choose default construction or zero-initialization as
> appropiate. And IMO that magic would be best placed within
> boost::in_place() itself since it makes a lot of sense, given its nature,
> to do
> zero-initialization for non-default constructible types.
>
> With such a smart in_place factory, the optional swap implementation would
> look exactly as you proposed it AFAICT.

If I'm following, you're proposing calling swap on an object which doesn't
really exist, but is just a zero'ed block of memory? Wouldn't that be
undefined behavior? Suppose the template type contains a mutex and its swap
specialization tries to lock the mutexes for both objects before swapping
their contents. It would crash wouldn't it?

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

iD8DBQFH/81V5vihyNWuA4URAvTbAKDaYhtp2O7eeo150sscSRgcJ3VVFQCeNjvP
dG2Px8pwBvZkHHOd7GGJvHo=
=Qwdg
-----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