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 08:22:23


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
> specializations.

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".

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?

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