Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[conv.fcttpr] Clarify the definition and the corresponding examples #5822

Open
xmh0511 opened this issue Sep 12, 2022 · 0 comments
Open

[conv.fcttpr] Clarify the definition and the corresponding examples #5822

xmh0511 opened this issue Sep 12, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 12, 2022

[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 T and U are the same function type except that T has a non-throwing exception specification and U has 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant