-
Notifications
You must be signed in to change notification settings - Fork 9
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
Prevent calling make_optional<int&>(i) or make_optional<const int&>(i) #59
base: main
Are you sure you want to change the base?
Commits on Sep 16, 2024
-
[CI] Allow users to manually trigger the CI and precommit workflows
Configuration menu - View commit details
-
Copy full SHA for 83674c8 - Browse repository at this point
Copy the full SHA 83674c8View commit details -
[test] Fix warnings from Clang trunk
`static_cast` to lvalue suppresses Clang's self-assignment warning. Add (missing?) EXPECTs to silence Clang's unused-variable warning. Add an accessor to suppress Clang's unused-private-field warning. Drive-by rename "empty_base" to "disengaged_base", since the phrase "empty base" means something different in C++.
Configuration menu - View commit details
-
Copy full SHA for 50d8616 - Browse repository at this point
Copy the full SHA 50d8616View commit details -
Configuration menu - View commit details
-
Copy full SHA for 926663c - Browse repository at this point
Copy the full SHA 926663cView commit details -
Configuration menu - View commit details
-
Copy full SHA for eba41fd - Browse repository at this point
Copy the full SHA eba41fdView commit details -
Support optional<optional<int>&>
Add two new tests: one for `optional<optional<int>&>`, and one testing that we can construct and assign to `optional<T&>` from `reference_wrapper<T>` (which should work: since `reference_wrapper<T>` is implicitly convertible to `T&`, it also should be implicitly convertible to `optional<T&>`). These tests are both red before this patch and green afterward.
Configuration menu - View commit details
-
Copy full SHA for cd93469 - Browse repository at this point
Copy the full SHA cd93469View commit details -
Configuration menu - View commit details
-
Copy full SHA for fbf4b1c - Browse repository at this point
Copy the full SHA fbf4b1cView commit details -
Support binding optional<const T&> to a non-const T, and add tests
The new tests are red before the patch and green afterward.
Configuration menu - View commit details
-
Copy full SHA for a6333d3 - Browse repository at this point
Copy the full SHA a6333d3View commit details -
Support optional<T&>::emplace, and add tests
The return type of `emplace` had been wrong; `emplace` returns a reference to the emplaced value (in this case, the T& reference that was bound), not `*this`. The new tests are red before the patch and green afterward.
Configuration menu - View commit details
-
Copy full SHA for 986b975 - Browse repository at this point
Copy the full SHA 986b975View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4448d97 - Browse repository at this point
Copy the full SHA 4448d97View commit details
Commits on Sep 18, 2024
-
[test] Add another green test for overload resolution
This test fails with at least one alternative approach to the constructor overload set (involving =delete'd candidates which make this overload resolution ambiguous).
Configuration menu - View commit details
-
Copy full SHA for 8767b1e - Browse repository at this point
Copy the full SHA 8767b1eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4422189 - Browse repository at this point
Copy the full SHA 4422189View commit details -
Prevent calling make_optional<int&>(i) or make_optional<const int&>(i)
The status quo in C++23 is that int i; auto o = make_optional<int&>(i); produces an `optional<int>`, not an `optional<int&>`. This would be horribly confusing to propagate into C++26 — users would naturally expect to receive an `optional<int&>`. Worse, auto o = make_optional<int&>(std::ref(i)); actually *would* give you an `optional<int&>`, because it would use a different overload of `make_optional`! So, we propose to add a "Mandates" element to `make_optional` that requires its explicit template argument (if any) to be a non-array object type. This breaks the "status quo" example at the top of this comment (requiring an Annex C entry); but it successfully prevents the pitfalls. Thanks to Tomasz Kamiński for the template-programming trick, which matches the technique used in https://eel.is/c++draft/out.ptr .
Configuration menu - View commit details
-
Copy full SHA for 7f0aa7e - Browse repository at this point
Copy the full SHA 7f0aa7eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b8ce75 - Browse repository at this point
Copy the full SHA 9b8ce75View commit details