This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] libstdc++/51365 for shared_ptr

This fixes shared_ptr to allow 'final' allocators to be used.

As an added bonus it also reduces the memory footprint of the
shared_ptr control block when constructing a shared_ptr with an empty
deleter or when using make_shared/allocate_shared.

I decided not to use std::tuple here, because it's a pretty heavy
template to instantiate, so added another EBO helper like the one in
hashtable_policy.h -- they should be merged and reused for the other
containers to fix the rest of PR 51365.

        PR libstdc++/51365
        * include/bits/shared_ptr_base (_Sp_ebo_helper): Helper class to
        implement EBO safely.
        (_Sp_counted_base::_M_get_deleter): Add noexcept.
        (_Sp_counter_ptr): Use noexcept instead of comments.
        (_Sp_counted_deleter): Likewise. Use _Sp_ebo_helper.
        (_Sp_counted_ptr_inplace): Likewise.
        * testsuite/20_util/shared_ptr/cons/ New.
        * testsuite/20_util/shared_ptr/cons/ Add rebind member to
        custom allocator and test construction with custom allocator.
        * testsuite/20_util/shared_ptr/cons/ Adjust dg-error
        line number.

Tested x86_64-linux, committed to trunk.

Attachment: patch.txt
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]