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

P2405 nullopt_t and nullptr_t should both have operator and operator== #1075

Closed
wg21bot opened this issue Jul 30, 2021 · 3 comments
Closed
Labels
B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed size - small paper size estimate

Comments

@wg21bot
Copy link
Collaborator

wg21bot commented Jul 30, 2021

P2405R0 nullopt_t and nullptr_t should both have operator and operator== (Justin Bassett)

@wg21bot wg21bot added the LWG Library label Jul 30, 2021
@wg21bot wg21bot added this to the 2021-telecon milestone Jul 30, 2021
@cor3ntin cor3ntin added LEWG Library Evolution ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list and removed LWG Library labels Jul 31, 2021
@brycelelbach brycelelbach added B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e IS Ship vehicle: IS size - small paper size estimate labels Aug 1, 2021
@brycelelbach brycelelbach added the scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review label Sep 24, 2021
@inbal2l
Copy link
Collaborator

inbal2l commented Nov 4, 2021

Was seen by mailing list review on 2021-08-30. Attaching a short summary of the comments:

Summary

  1. The proposal generally got support.

  2. Please make sure the proposal is seen by EWG

  3. Make sure the wording avoids p < nullptr comparisons (the current version is probably OK).

  4. Suggestion: add comparison with nullptr:

    • For:
      Would like the paper to discuss:
      nullptr < p and p > nullptr, for all non-null pointers pnullptr <= p and p >= nullptr, for all pointers p
      Changing the language semantics so that comparisons of raw-ptrs with pointers of that type and null value, would be defined and make it "smallest" element, will fix the issue (because less<>) need to be compatible with it. The other option would be to impose this as additional requirement on total order produced on ptrs by less<>. But, with the current context, I am opposed to adding operator<=> to nullptr.
      This is why I do not see this as orthogonal to the paper.

    • Against:
      nullptr is not a pointer value; it's just a placeholder that can be converted to a value of pointer type.  At that point,
      you got a null pointer value of a specific type, which can fully participate in comparisons (to the extent such
      comparisons are meaningful). You can only compare pointer values of the same type, and appropriate conversions on the operands ensure a common type is established before performing the comparison.(same for nullopt)
      That was Core DR 583 resolved by N3478
      If you want to write that generic code, use a facility that gives you a well-formed and well-defined ordering of all pointers. The language comparison operator for raw pointers doesn't.

  5. Suggestion: make std::less<> well-formed and well-defined for a nullptr

    • For:
      The motivation of the paper is to allow painless comparison and searching against nullptr. The question is how many of operations would be useful (remove, equal_range), and how many of them, may lead to not-portability, due assumption of certain ordering of null wrt not null. And weigh these two, given that there exists a simple alternative, as passing std::equal_to/std::less instead of std::ranges::less,std::ranges::equal to this function.

    • Against:
      For raw pointers, less<> is not well-formed for nullptr and pointers, because there is no implementation-defined strict total order of nullptr and a pointer.
      less<> is not well-formed for nullptr and pointers, because there is no implementation-defined strict total order of nullptr and a pointer. clang+libc++ accepts it because they deliberately hack it to work (here: llvm L11978) and in msvc+stlstl it works because msvc doesn't yet implement the language change that makes comparing a nullptr and a pointer ill-formed.

Outcome

Please provide a new revision addressing topics (4) and (5) above. (to clarify - I'm asking to document the topics and the author's perspective, not necessarily to add the suggestions). 

@inbal2l inbal2l added needs-revision Paper needs changes before it can proceed and removed ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review labels Nov 4, 2021
@jensmaurer jensmaurer removed this from the 2021-telecon milestone Nov 12, 2021
mordante pushed a commit to llvm/llvm-project that referenced this issue Aug 2, 2022
    * `operator<=>` for `iota_view::iterator` was enabled in 8320017
    * Removed P2405R0 which was not accepted and seems inactive
      (cplusplus/papers#1075)
    * Added the previously missing `operator==` for `filesystem::space_info`
      to the tracking list.
    * Updated the "Assignee" for `string_view`, `string` as Mark de Wever
      mentioned he is working on them in Discord
    * Updated the status of the items for which I sent review requests
      yesterday.

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D130855
@brycelelbach
Copy link

Closing due to more than 1 year of inactivity. Please re-open if further work is expected.

@Quincunx271
Copy link

I do expect to continue working on this sometimes in the next few months. I just need to arrange the time to be able to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed size - small paper size estimate
Projects
None yet
Development

No branches or pull requests

6 participants