Skip to content

[func.wrap.ref.deduct] simplify wording#8955

Open
zhihaoy wants to merge 1 commit intocplusplus:mainfrom
zhihaoy:patch-3
Open

[func.wrap.ref.deduct] simplify wording#8955
zhihaoy wants to merge 1 commit intocplusplus:mainfrom
zhihaoy:patch-3

Conversation

@zhihaoy
Copy link
Copy Markdown
Contributor

@zhihaoy zhihaoy commented Apr 20, 2026

No description provided.

@frederick-vs-ja
Copy link
Copy Markdown
Contributor

This seems to be a functional change and thus perhaps requires an LWG issue.

The 2nd template argument of constant_wrapper is possibly provided by the user (and thus can be a function type whatever c is), and the change will affect such (pathological, IMO) uses. Presumably these deduction guides should rely on constant_wrapper::value_type.

@eisenwave eisenwave added lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. labels Apr 20, 2026
@eisenwave
Copy link
Copy Markdown
Member

Yeah right, https://eel.is/c++draft/const.wrap.class#lib:constant_wrapper doesn't put any Constraints or Mandates on the second template parameter; so it could be literally anything.

Concretely, the proposed change makes it invalid to use the deduction guide with constant_wrapper</* ... */, int()> because remove_pointer_t accepts non-pointers, but F* would fail deduction.

@zhihaoy
Copy link
Copy Markdown
Contributor Author

zhihaoy commented Apr 20, 2026

Concretely, the proposed change makes it invalid to use the deduction guide with constant_wrapper</* ... */, int()> because remove_pointer_t accepts non-pointers, but F* would fail deduction.

Then we got a bigger problem: function_ref(std::constant_wrapper<nullptr, int()>{}) can bypass the ctor's Mandates and break the class invariant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lwg Issue must be reviewed by LWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants