|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-06-26 11:29:26
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 26 June 2008 10:51 am, David Abrahams wrote:
> > Don't you think it /always/ makes sense to provide a custom
> > swap overload for a Swappable type, as long as it outperforms the
> > default std::swap, in one way or the other?
>
> That's the whole question. I'm not 100% sure.
I'd say if the default std::swap compiles for the type, then there is no
reason not to provide a more efficient swap specialization. The only
question for me would be in a case where the type is not assignable/copy
constructible. Then you might want to have a compile error instead of a non
O(1) swap. But given that the default std::swap can in reality already have
arbitrary complexity, depending on the complexity of a type's assignment/copy
constructor, I don't see much value in producing a compile error.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIY7Xf5vihyNWuA4URArlXAKDFqOtlL14dwWbVODm2cKHv8N+KGACdGkKR
a3I9hVHxt2AEl6iLLffROfE=
=HMY+
-----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