[cfe-dev] http://llvm.org/bugs/show_bug.cgi?id=11462
Eli Friedman
eli.friedman at gmail.com
Fri Dec 2 12:46:33 PST 2011
On Fri, Dec 2, 2011 at 12:00 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> I would like to draw clang developer's attention to:
>
> http://llvm.org/bugs/show_bug.cgi?id=11462
>
> This is a feature request for a new intrinsic __is_final(T).
>
> This intrinsic has become necessary due to the recent C++ language addition "final". The problem is that many libraries (such as libc++) will derive from types they know nothing about except that the type is a class and is eligible for the empty base optimization.
>
> libc++ uses this technique in no less than 5 places to optimize away space for allocators, deleters, predicates, etc. It makes all containers smaller, and is what enables sizeof(unique_ptr) == sizeof(void*). I.e. it is a critically important optimization.
>
> Now that our customers can write:
>
> class final A {};
>
> we find ourselves in the position that libc++ will attempt to derive from A in a surprising number of places (because it is empty), only to result in a compile time error because A is also final. Thus libc++ needs a way to check classes for final.
>
> Ganesh has proposed a patch to clang to implement __is_final, complete with a __has_feature check. libc++ really needs this so that our clients can write:
>
> std::tuple<A> t;
>
> Comments? Questions?
It seems reasonable, and I can't think of any other usable solution.
-Eli
More information about the cfe-dev
mailing list