isocpp / isocpp/CppCoreGuidelines
suggestion: R.n (extend R.35,R.36) for shared_ptr<widget>&& parameter
@hsutter is already working on this.
Since Jun 10, 2021.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
Title might be like:
R.n: Take a shared_ptr<widget>&& parameter to express that caller is expected to transfer "it's" reference count
I'm about to design this into an interface. The background thought is, that there is something like a "primary owner", although ownership is shared technically. shared_ptr is needed for some reason external to the function that takes the argument (in this case: weak_ptr are necessary to cross-reference objects owned by the smart pointers).
The envisioned situation at the callers side is constructing an object and handing it over to the "primary owner". To express that the caller is requested to transfer ownership instead of sharing it, a rvalue reference is used for the parameter. (Of course nothing technically prevents the caller from retaining a copy of the shared_ptr, but the interface expresses that the expectation is otherwise.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.