[unique.ptr.general] Intro wording is misleadingly restrictive
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
https://eel.is/c++draft/unique.ptr.general#1 (and remaining) paragraphs make overly restrictive claims:
- a unique pointer owns an object
- a unique pointer stores a pointer
Neither of these claims are necessarily true. The following program is valid, and compiles with libc++:
#include <memory>
struct deleter {
using pointer = int(*)();
void operator()(pointer) const {}
};
int main() {
std::unique_ptr<int&, deleter> ptr;
ptr.get();
}
- What is the owned object here? Neither
int&norint()are objects types. - While
pointeris actually a pointer in this example, it is generally any pointer-like type that satisfies NullablePointer. It's not required to be a pointer.
I think it's all arguably not a big problem, and this is simply questionable wording in the semi-normative intro paragraphs. However, it's also not nice that the wording is making claims that get contradicted/superseded/corrected by later wording. It would be nice if this wasn't the case.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with the linked unique.ptr.general section and read the introductory and remaining paragraphs together, then compare their descriptions with the NullablePointer requirements and the example in the issue. Done means the introductory wording no longer makes claims contradicted by the later specification; the issue does not name a repository file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100