|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-10 16:53:40
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 10 April 2008 16:02 pm, Thorsten Ottosen wrote:
> > Your approach requires the T to be default constructible which is not
> > always the case.
>
> Why is this better than the far more expensive copy-construction?
The documentation indicates optional<T> requires T to be copy constructible.
It explicitly does not require T to be default constructible.
> > Besides, to my mind, the current implementation is more
> > obvious for the user.
>
> No user expects swap to throw or invalidate iterators or references like
> the current implementation does.
Personally, I consider any preservation of iterators/references/pointers to
the internals of a swapped object to be purely a side-effect of a swap
specialization, whose raise d'etre is as a speed optimization.
- --
Frank
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFH/n5V5vihyNWuA4URAr9RAJ4q7fodOLKbArYSBzTbosEwQHKWvACcDs8d
AukOjKNmV5bJ70lp6ozcp8g=
=zPA9
-----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