[libcxx-commits] [libcxx] Reapply "[libc++] Avoid constructing additional objects when using map::at" (#160738) (PR #161485)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 3 08:13:11 PDT 2025
frederick-vs-ja wrote:
> ```c++
> namespace std {
> template <>
> struct less<::Paper> {
> bool operator()(const ::Paper& lhs, const ::Paper& rhs) const {
> return lhs.a < rhs.a;
> }
> };
> }
> ```
@nico This specialization looks invalid to me, as the `operator()` of the original template is ill-formed when instantiated (assuming there's no valid `operator<`), but the specialization additionally makes it valid. It seems that we can't statically diagnose such semantic requirement violation.
Although it's permitted to specialize `std::less`, it's quite hard to to make such specialization both meaningful and valid. Perhaps a valid and meaningful one would impose some stricter order around pointer comparison.
https://github.com/llvm/llvm-project/pull/161485
More information about the libcxx-commits
mailing list