From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-04-12 05:58:58
Corrado Zoccolo skrev:
> On Fri, Apr 11, 2008 at 9:38 AM, Sebastian Redl <
> sebastian.redl_at_[hidden]> wrote:
>> 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.
> We can use has_nothrow_default_constructor .
> This will also exclude the specialization when the default constructor
> performs some allocation, and could result in lower performance.
I can't imagine that it would result in lower performance in general ...
have you seen many types for which default construction was more
expensive than copy-construction?
has_nothrow_default_constructor is certainly useable, albeit it requires
compiler inrinsics. Do we know how many compilers that do support them?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk