Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Yuriy Zubritsky (mt.wizard_at_[hidden])
Date: 2012-04-27 23:56:08
I looked into make_shared.hpp you attached, and saw several bug in it. Do
you know how to remove it from ticket?
Here are the bugs:
1. verify_allocation should check passed pointer only in no-exception mode.
If exceptions are enabled, allocator::allocate is required to throw
bad_alloc, so no check is needed
2. sp_enable_shared_from_this() is called from shared_ptr constructor, so
there's no need to call it in make_shared()
3. I made make_shared.hpp to look differently as it was rewritten. No need
to make it looking same way.
Both #1 and #2 decrease performance of make_shared a little. Also, #1
prevents it from correct handling of allocation failure if exceptions are
I recommend you to use original version from patch
2012/4/26 Ivan Erceg <ierceg_at_[hidden]>
> Yuriy Zubritsky <mt.wizard <at> gmail.com> writes:
> > >> and added #defines leaving non-MSVC part intact
> > This isn't needed. I wrote it to be cross-platform, and it also
> > optimization Stephen wrote about ("we know where you live").
> > I tested my code on msvc 9 - 11, gcc 4.6, 4.7 and clang.
> I figured as much re cross-platform but I don't have anything to test with
> except VC9/10. I'll drop the related #defines and attach the updated
> smart_ptr\make_shared.hpp to your ticket.
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk