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>? 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

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>: 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, gregod at, cpdaniel at, john at