Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Ivan Erceg (ierceg_at_[hidden])
Date: 2012-05-02 11:11:49

Yuriy Zubritsky <mt.wizard <at>> writes:

> I looked into make_shared.hpp you attached, and saw several bug in it. Do
> you know how to remove it from ticket?

No, I don't. I tried but couldn't find an option. My apologies for polluting
your 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

This is my mistake. I have fixed it.

> 2. sp_enable_shared_from_this() is called from shared_ptr constructor, so
> there's no need to call it in make_shared()

I see what you mean. I have removed it.

> 3. I made make_shared.hpp to look differently as it was rewritten. No need
> to make it looking same way.

I think that lowering the "friction" between what you wrote and the original is
desirable as neither you nor I are the library maintainers.

> Both #1 and #2 decrease performance of make_shared a little. Also, #1
> prevents it from correct handling of allocation failure if exceptions are
> disabled
> I recommend you to use original version from patch
> Thanks

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