Bug 234117 - Use simpler idioms for std::less and std::greater possible in modern C++
Summary: Use simpler idioms for std::less and std::greater possible in modern C++
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P3 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-09 18:06 PST by Darin Adler
Modified: 2021-12-10 10:19 PST (History)
7 users (show)

See Also:


Attachments
Patch (4.39 KB, patch)
2021-12-09 18:09 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (4.40 KB, patch)
2021-12-09 20:26 PST, Darin Adler
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2021-12-09 18:06:51 PST
Use simpler idioms for std::less and std::greater possible in modern C++
Comment 1 Darin Adler 2021-12-09 18:09:21 PST
Created attachment 446649 [details]
Patch
Comment 2 Darin Adler 2021-12-09 20:26:39 PST
Created attachment 446657 [details]
Patch
Comment 3 Anders Carlsson 2021-12-10 10:07:35 PST
Comment on attachment 446657 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446657&action=review

> Source/WTF/wtf/ListDump.h:124
> +    return sortedListDump(list, std::less<>(), comma);

Is there a reason why std::less() does not work here? Maybe because it's in an uninstantiated context?
Comment 4 Darin Adler 2021-12-10 10:13:32 PST
Comment on attachment 446657 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446657&action=review

>> Source/WTF/wtf/ListDump.h:124
>> +    return sortedListDump(list, std::less<>(), comma);
> 
> Is there a reason why std::less() does not work here? Maybe because it's in an uninstantiated context?

I know it doesn’t because my earlier patch failed to compile (gcc), but it did seem to compile locally (clang), so it might be a workaround for a gcc bug.

I suspect it has something to do with the fact that the comparator argument to sortedListDump is "const Comparator&" and the comparator argument to sort is "Comparator", but the fact that it does seem to work in clang confuses me a bit.
Comment 5 Darin Adler 2021-12-10 10:18:14 PST
Committed r286858 (?): <https://commits.webkit.org/r286858>
Comment 6 Radar WebKit Bug Importer 2021-12-10 10:19:20 PST
<rdar://problem/86328234>