C++ Logo

std-discussion

Advanced search

Pointer comparison with operators vs function objects

From: Yongwei Wu <wuyongwei_at_[hidden]>
Date: Mon, 15 Sep 2025 20:48:52 +0800
As per my understanding of the C++ standard, operators like < should not be
used to compare unrelated pointers, but function objects like std::less
can. Is there any reason why we cannot make p1 < p2 just behave like
std::less<T*>{}(p1, p2)? I really cannot think any.

Any insights on this?

-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

Received on 2025-09-15 12:49:06