From: David Abrahams (dave_at_[hidden])
Date: 2008-08-27 10:23:21
on Wed Aug 27 2008, "Niels Dekker - mail address until 2008-12-31" <nd_mail_address_valid_until_2008-12-31-AT-xs4all.nl> wrote:
> David Abrahams wrote:
>> What was wrong with my proposal?
>> You can't guarantee it will be right every time, but it's easy to
>> correct when wrong, and that would only take a very few
> Please note: The question is /not/ whether T has a custom swap. The
> question is whether default-construction + swap outperforms
> copy-construction for type T. Only in that case, it makes sense to
> activate "Swaptimization".
Of course. 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? Maybe my imagination is failing me, but I can't.
> Anyway, I agree, your approach provides a reasonable first guess:
>> std is an associated namespace of T
>> ? has_member_swap<T>
>> : has_nonmember_swap<T>
> So for such a type T, _Move_operation_category<T>::_Move_cat should be
> set to "_Swap_move_tag", instead of "_Undefined_move_tag", by
> default. Do you know how we can technically overrule the default
> _Move_operation_category<T> provided by MSVC's STL?
> In ConceptC++, it
> would look a little bit like this:
> template <class T> where HasCustomSwap<T> // Pseudo ConceptC++
> struct _Move_operation_category<T>
> typedef _Swap_move_tag _Move_cat;
> But how to do that in C++03?
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.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com