Boost logo

Boost :

From: Niels Dekker - mail address until 2008-12-31 (nd_mail_address_valid_until_2008-12-31_at_[hidden])
Date: 2008-08-27 12:13:04


David Abrahams wrote:
> But can you come up with a type where it makes sense to have
> written a custom swap but default-construction + swap won't
> outperform copy construction?

What do you think of the ticket I recently submitted, requesting custom
swap functions for value_initialized<T>?
http://svn.boost.org/trac/boost/ticket/2243 After having added
value_initialized<T>::swap according to the ticket, it would very much
depends upon T whether or not default-construction + swap would
outperform copy-construction, for value_initialized<T>.

>> Do you know how we can technically overrule the default
>> _Move_operation_category<T> provided by MSVC's STL?
>
> If they didn't give us any further hooks (such as a default argument)
> to hang a specialization on, then sadly I don't know of a way.

Their macro _DEFAULT_MOVE_OPERATION_CATEGORY looks a little bit like a
hook, but it wasn't intended that way, as Stephan T. Lavavej told me at
http://blogs.msdn.com/vcblog/archive/2008/08/11/tr1-fixes-in-vc9-sp1.aspx

A related issue: the trunk version of Boost Optional now allows
boost::optional<T>::swap to be tweaked in a similar way, following a
request by Thorsten, here at [boost]. Optional's swap function uses
default-construction + swap when specified by
boost::optional_swap_should_use_default_constructor<T>:
http://svn.boost.org/svn/boost/trunk/boost/optional/optional.hpp I
think it would be preferable to have Optional's swap tweaking based upon
the same type traits that activate "Swaptimization" on MSVC's STL.

Kind regards, Niels


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk