Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Ahmed Charles (ahmedcharles_at_[hidden])
Date: 2012-04-28 21:16:47


> You don't need a special case for emptiness if you make them base
> classes when they're classes (a.k.a. use boost::compressed_pair)
>
>> In VC11, we've introduced such special-casing for container
>> allocators/comparators, but we haven't had time to extend it to
>> shared_ptr. I've made a note to myself to do this in the future.
>
> That's what compressed_pair is for; you don't have to keep repeating the
> same special case over and over ;-)

The downside of having it be a base class is that classes can now be
marked final, which means they can't be used as base classes. This
approach was used by libc++ for implementing the same optimization
that STL mentions VC's STL implements, but I think they end up falling
back to storing it if it's empty and final.

I suppose what we really want is static if. :)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk