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

optional<const in_place_t> should be ill-formed #38

Open
jwakely opened this issue Jul 18, 2024 · 1 comment
Open

optional<const in_place_t> should be ill-formed #38

jwakely opened this issue Jul 18, 2024 · 1 comment
Assignees

Comments

@jwakely
Copy link

jwakely commented Jul 18, 2024

https://github.com/beman-project/Optional26/blob/bfeb9080c0d9c501965ae857a1decf7ed74686f5/include/Beman/Optional26/optional.hpp#L297-L299

This only rejects in_place_t not cv in_place_t as required by [optional.optional.general] p3.

For the second constraint, why decay_t instead of remove_cv_t?

Do you really want these constraints in the first place? Using static_assert to enforce these rules is likely to support better diagnostics. Also, constraining the primary template with a requires-clause means that these constraints will be checked for the optional<T&> specialization when that is added. That won't be wrong because T& will never match in_place_t or nullopt_t but it's just unnecessary compile-time overhead to check constraints that will never match.

Finally, why is this requires-clause using redundant parentheses, like it's a function call? That style seems to be used inconsistently throughout the file. Edit: sorry, was looking at the wrong file when I wrote that! The parens in requires-clauses in the Beman/Optional26 code are fine.

@steve-downey steve-downey self-assigned this Jul 18, 2024
@steve-downey
Copy link
Member

The lack of cv is probably me glossing over that in
T shall be a type other than cv in_place_t or cv nullopt_t that meets the Cpp17Destructible requirements (Table 35).

Should be able to move these to a static_assert in the definition of the template, also improving diagnostics instead of removing them from the overload set / making them not exist.

steve-downey added a commit to steve-downey/optional that referenced this issue Jul 22, 2024
Change to static_assert and remove_cv_t. See issue bemanproject#38
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

2 participants