
Thorsten Ottosen wrote:
Andrey Semashev skrev:
Thorsten Ottosen wrote:
Andrey Semashev skrev:
Your approach requires the T to be default constructible which is not always the case.
Why is this better than the far more expensive copy-construction?
1. It adds a new requirement to T.
But only for swap().
It's still a new requirement, which I find quite unacceptable. Suddenly I can't swap types without default constructors anymore? If this variant of swap() is really more efficient, perhaps metaprogramming could be used to support it *if* the type has a default constructor. But I don't know how to detect this. TypeTraits doesn't contain a has_default_constructor trait. It may be that this will only work with 09 concepts - DefaultConstructible. Sebastian