[Bug libstdc++/95245] std::sort copies custom comparator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95245 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2020-05-20 Ever confirmed|0 |1 Keywords||missed-optimization --- Comment #2 from Jonathan Wakely --- I think other implementations automatically wrap the function in a reference-like type. See PR 51965 for similar issues with other recursively-defined algorithms. N.B. GCC 7 is no longer supported or maintained, so bug reports should be for currently-supported versions.
[Bug libstdc++/95245] std::sort copies custom comparator
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95245 --- Comment #1 from Jonathan Wakely --- [algorithms.requirements] paragraph 10 says: [Note: Unless otherwise specified, algorithms that take function objects as arguments are permitted to copy those function objects freely. Programmers for whom object identity is important should consider using a wrapper class that points to a noncopied implementation object such as reference_wrapper 20.14.5), or some equivalent solution. — end note]