[conv.fcttpr] Clarify the definition and the corresponding examples
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 221
- Forks
- 813
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 36
Description
[conv.fctptr] p1 says
A prvalue of type “pointer to noexcept function” can be converted to a prvalue of type “pointer to function”. The result is a pointer to the function.
Presumably, the definition works if and only if such two pointers point to the same function type except for exception specification. In the current wording, we seem not to give the restriction to the function types in the establishment of the conversion.
Suggested resolution
A prvalue of type “pointer to function type T” can be converted to a prvalue of type “pointer to function type U” where
TandUare the same function type except thatThas a non-throwing exception specification andUhas a potentially-throwing exception specification. The result is a pointer to the function.
The same is true for the pointer to member function conversion.
In the current examples, the listed case is a bit irrelevant to the conversion
void (*p)();
void (**pp)() noexcept = &p; // error: cannot convert to pointer to noexcept function
The definition works only if we have a "pointer to function type" rather than "pointer to pointer to function type". Even though, the example would be
void (*p)() noexcept;
void (**pp)() = &p;
The relevant example should be changed to
void (*p)() noexcept;
void(*p1)() = p; // ok
void(*p2)() noexcept = p1; // error
struct S{
void fun() noexcept {}
};
void(S::*p3)()= &S::fun;
void(S::*p4)() noexcept = p3;
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 by reading [conv.fctptr] p1 and the conversion examples quoted in the issue. Compare the wording and examples with the proposed function-pointer and pointer-to-member-function cases; the work is done when the restriction on function types and the corresponding valid and invalid conversions are clearly represented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100