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

use std::less instead of < for comparison #880

Closed
Jarod42 opened this issue Apr 28, 2020 · 2 comments · Fixed by #1106
Closed

use std::less instead of < for comparison #880

Jarod42 opened this issue Apr 28, 2020 · 2 comments · Fixed by #1106
Labels

Comments

@Jarod42
Copy link

Jarod42 commented Apr 28, 2020

using < to compare unrelated pointers give unspecified result according to standard.
std::less should be consistent (even if I don't know any implementation of std::less which is different than lhs < rhs).

@attilaszenczi
Copy link

attilaszenczi commented Apr 30, 2020

Note: The issue is about the case
using KeyT = gsl::not_null<T>;
std::map<KeyT, ValueT>

@hsutter
Copy link
Collaborator

hsutter commented Apr 26, 2023

Editors call: Yes, in not_null where we do t < t, we should do std::less(t, t).

dmitrykobets-msft added a commit that referenced this issue May 9, 2023
…sons with `not_null` (#1106)

Using `<`,`<=`,`>`,`>=` to compare unrelated pointers gives an unspecified result according to the standard.
This PR replaces the usage of these operators in `gsl::not_null` with the STL counterparts, which would leverage any implementation-defined strict total ordering for pointers.

Resolves #880
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants