This is the mail archive of the mailing list for the libstdc++ 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] std::unique_ptr<T[], D> improvements

This patch started when I noticed that it's not possibly to construct
a shared_ptr<T> from unique_ptr<T[], D>, then I discovered we don't
use D::pointer if it exists, and there were a number of other
non-conformance issues with our std::unique_ptr<T[], D>.  I ended up
fixing them by implementing Geoffrey's proposed resolution for LWG
issue 2118, which isn't official yet but is better than what we had
before so is a step in the right direction, even if it ends up needing
further revision when 2118 is resolved.

        * include/std/functional (_Require): Move to ...
        * include/std/type_traits (_Require): ... here.
        * include/bits/shared_ptr_base.h (__shared_count::_S_create_from_up):
        Handle unique_ptr for arrays or with custom pointer types.
        (__shared_ptr::__shared_ptr(unique_ptr<_Tp1, _Del>&&): Likewise.
        * include/bits/unique_ptr.h (unique_ptr<_Tp[], _Dp>): Use
        _Dp::pointer if defined. Implement proposed resolution of LWG 2118.
        * testsuite/20_util/shared_ptr/cons/ New.
        * testsuite/20_util/unique_ptr/assign/ New.
        * testsuite/20_util/unique_ptr/cons/ New.
        * testsuite/20_util/unique_ptr/cons/ New.
        * testsuite/20_util/unique_ptr/cons/ New.
        * testsuite/20_util/unique_ptr/modifiers/ New.
        * testsuite/20_util/unique_ptr/requirements/ New.
        * testsuite/20_util/shared_ptr/cons/ Adjust comments.
        * testsuite/20_util/unique_ptr/cons/
        * testsuite/20_util/unique_ptr/requirements/ Likewise.
        * testsuite/20_util/bind/ Adjust dg-error line number.
        * testsuite/20_util/declval/requirements/ Likewise.
        * testsuite/20_util/default_delete/ Likewise.
        * testsuite/20_util/shared_ptr/cons/ Likewise.
        * testsuite/20_util/unique_ptr/assign/ Likewise.
        * testsuite/20_util/unique_ptr/modifiers/ Adjust
        dg-error text.
        * testsuite/20_util/unique_ptr/cons/ Use
        different instantiations so static_assert fails for each.

Thanks to Geoffrey and Lawrence for input and test cases.

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]