Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-04-26 01:33:55

on Wed Apr 25 2012, "Stephan T. Lavavej" <> wrote:

> [Mathias Gaunard]
>> std::shared_ptr is probably optimized for empty or default deleters.
> In VC10 and VC11, shared_ptr has five control blocks:
> * vanilla
> * custom deleter
> * custom deleter and custom allocator
> * make_shared
> * allocate_shared
> Each is optimally sized (in particular, make_shared/allocate_shared
> implement the "we know where you live" optimization that I have
> previously described

I can't find that description. Pointer please?

> in an attempt to get Boost to pick it up), except that we don't
> special-case empty custom deleters/allocators.

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 ;-)

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at