Page MenuHomePhabricator

shared_ptr changes from library fundamentals (P0414R2)
Needs ReviewPublic

Authored by zoecarver on May 22 2019, 8:44 AM.

Details

Reviewers
mclow.lists
ldionne
EricWF
Group Reviewers
Restricted Project
Summary

This patch is a WIP to support P0414R2.

Diff Detail

Event Timeline

zoecarver created this revision.May 22 2019, 8:44 AM
zoecarver edited the summary of this revision. (Show Details)
  • fully implement the paper
  • add tests
  • Add unsupported and _NOEXCEPT. Now works in C++03.
zoecarver marked an inline comment as done.May 27 2019, 11:40 AM
zoecarver added inline comments.
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
42 ↗(On Diff #201558)

I am not so sure about shared_ptr<void>. The standard says "The expression delete[] p, when T is an array type, or delete p, when T is not an array type, shall have well-defined behavior, and shall not throw exceptions." Meaning that delete T must be well defined. But the standard also says delete void is not well defined: "This implies that an object cannot be deleted using a pointer of type void* because there are no objects of type void." Therefore, I think shared_ptr<void> goes against the standard.

Either way, for the overload tested here, we will have to pick between creating a deleter for type T and type Y. The former works for arrays and the latter works for void.

zoecarver marked an inline comment as done.May 31 2019, 7:17 PM
zoecarver added inline comments.
include/memory
3741 ↗(On Diff #201558)

Use add_lvalue_reference.

zoecarver marked an inline comment as done.Jun 6 2019, 7:38 PM
zoecarver added inline comments.
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
42 ↗(On Diff #201558)

The standard says delete p must be well defined. Meaning delete Y must be well defined. Not delete T. My bad.

zoecarver updated this revision to Diff 203479.Jun 6 2019, 7:59 PM
  • fix test issues
  • fix diff issues
  • fix void issues
zoecarver marked an inline comment as done.Jun 6 2019, 8:00 PM
zoecarver added inline comments.
include/memory
4028 ↗(On Diff #203479)

I don't love this "hack", but I am not sure there is a better way to fix the issue I describe below. Suggestions are more than welcome.

zoecarver updated this revision to Diff 246976.Feb 27 2020, 9:10 AM
  • Rebase off master
  • Remove references to D66177
  • Incorporate changes (tests) from D62103
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 27 2020, 9:10 AM
zoecarver updated this revision to Diff 246978.Feb 27 2020, 9:11 AM
  • Diff from master (not whatever phabricator selected...)
zoecarver updated this revision to Diff 246980.Feb 27 2020, 9:14 AM
  • Remove accidentally added files (.rej and weak_ptr_Y)
zoecarver updated this revision to Diff 246981.Feb 27 2020, 9:17 AM
  • Remove remaining .rej files

    Sorry for all the updates.
  • Run everything through clang-format
  • Fix failing test after formatting change

Ping. This patch now has no references to any other patches so it can now be merged immediately.

Herald added a reviewer: Restricted Project. · View Herald TranscriptSat, Mar 14, 2:39 PM