-
-
Save danlark1/2a5b5b79bf23578b8e9043928dd0babc to your computer and use it in GitHub Desktop.
stability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<std::pair<int, int>> first_elements_equal{{1, 1}, {1, 2}}; | |
std::sort(first_elements_equal.begin(), | |
first_elements_equal.end(), | |
[](const auto& lhs, const auto& rhs) { | |
// Compare only by a part of sorted data. | |
return lhs.first < rhs.first; | |
}); | |
// Serialize or make assumptions about all data. | |
// Wrong, might be either 1 or 2. | |
assert(first_elements_equal[0].second == 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment