Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2012-04-30 13:09:45


On 30.04.2012, at 18:51, Mathias Gaunard wrote:

> On 29/04/12 03:16, Ahmed Charles wrote:
>
>> 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. :)
>
> Everything you could do with static if you can already do without, just with more verbose syntax.
>
> In this particular case, however, I don't see how any if-like technique would help. I cannot think of a method to tell whether a type is empty without inheriting from it.

std::is_empty, of course. The implementation is up to the standard library - Clang provides an __is_empty trait intrinsic since we discovered the final class problem of the classic library implementation.

Sebastian