Skip to content

[2026-03 LWG Motion 16] P3948R1 constant_wrapper is the only tool needed#8878

Open
eisenwave wants to merge 1 commit intocplusplus:mainfrom
eisenwave:motions-2026-03-lwg-16
Open

[2026-03 LWG Motion 16] P3948R1 constant_wrapper is the only tool needed#8878
eisenwave wants to merge 1 commit intocplusplus:mainfrom
eisenwave:motions-2026-03-lwg-16

Conversation

@eisenwave
Copy link
Copy Markdown
Member

Fixes #8850
Fixes NB FR-019-210 and FR-021-218 (C++26 CD).

Also fixes https://github.com/cplusplus/nbballot/issues/779
Also fixes https://github.com/cplusplus/nbballot/issues/788

… expressions via function arguments

Fixes NB FR-019-210 and FR-021-218 (C++26 CD).
@eisenwave
Copy link
Copy Markdown
Member Author

eisenwave commented Mar 28, 2026

@jwakely @mattkretz we have goofed HARD. The paper deletes constant_arg_t but not the deduction guides that function_ref has for it.

https://eel.is/c++draft/func.wrap.ref.deduct

(will deal with overfull hboxes once home btw)

\item
If \tcode{is_pointer_v<F> || is_member_pointer_v<F>} is \tcode{true},
then \tcode{f != nullptr} is \tcode{true}.
then \tcode{f != nullptr} is \tcode{true}, and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
then \tcode{f != nullptr} is \tcode{true}, and
then \tcode{f.value != nullptr} is \tcode{true}, and

@jwakely
Copy link
Copy Markdown
Member

jwakely commented Mar 28, 2026

@jwakely @mattkretz we have goofed HARD. The paper deletes constant_arg_t but not the deduction guides that function_ref has for it.

Can we just delete that (which is fine as an editorial change, because the draft is inconsistent if it refers to a type which no longer exists), or does it need to be changed to use constant_wrapper?

@eisenwave
Copy link
Copy Markdown
Member Author

eisenwave commented Mar 28, 2026

I believe the purpose of the deduction guides is to make things possible like

void f();
// CTAD
std::function_ref ref = std::nontype<f>;

Or now equivalently with std::cw<f>. If this no longer works as a result of deleting the deduction guides, that seems like an inadvertent design change.

I suppose the only editorial way to get the draft into a working state is to delete the deduction guides editorially and to reintroduce them by LWG issue. Any LWG resolutions won't be merged into the DIS anyway, right? We need to ship these motions.

@eisenwave eisenwave added this to the post-2026-03 milestone Mar 28, 2026
@zhihaoy
Copy link
Copy Markdown
Contributor

zhihaoy commented Mar 28, 2026

Herb reminded us that accepting motion can also introduce editorial change, so I suggest just finishing the renaming here.

@Mick235711
Copy link
Copy Markdown
Contributor

Personally, I support treating this as an editorial wording defect in the proposal, as the intention is obviously to replace all usage of constant_arg mechanically. In other similar renaming proposals, if the author left over a few instances in the wording, they are also editorially applied without LWG issues as long as the intention is clear when polling the motions.

@Bronek
Copy link
Copy Markdown
Member

Bronek commented Mar 29, 2026

@Mick235711 @zhihaoy I think in this case the intention was clear, so I would agree that this change should just replace constant_arg with constant_wrapper, ensuring that this CTAD works std::function_ref ref = std::cw<foo>; as long as that used to work std::function_ref ref = std::constant_arg<foo>; , for some nullary foo; and treat this as a necessary editorial.

EDIT: The intention was unfortunately not captured as clearly as I would wish, but my memory is rather clear that we wanted to "replace all the uses of constant_arg with constant_wrapper and remove constant_arg" and this is also what the paper being accepted says in the subject ("constant_wrapper is the only tool needed", emphasis mine)

@mattkretz
Copy link
Copy Markdown
Member

mattkretz commented Mar 29, 2026

  1. Sorry!
  2. I did change the deduction guide in my libstdc++ patch, so I really should have noticed by looking through the patch. 🤦
  3. I'll provide wording that matches a tested implementation and then we can decide whether we call that editorial or not. I agree that the intent of the change is very clear (replace constant_arg_t by constant_wrapper) and that the removal of constant_arg_t forces a (editorial) change to the deduction guide.

@mattkretz
Copy link
Copy Markdown
Member

This would be the necessary change for CTAD:
mattkretz@92a7ba1
I implemented it and it passes all (CTAD) tests in libstdc++.

@Bronek
Copy link
Copy Markdown
Member

Bronek commented Mar 29, 2026

This would be the necessary change for CTAD: mattkretz@92a7ba1 I implemented it and it passes all (CTAD) tests in libstdc++.

This looks like what we voted for in LEWG, i.e. design intent.

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

Successfully merging this pull request may close these issues.

[2026-03 LWG Motion 16] P3948R1 constant_wrapper is the only tool needed

6 participants