C++ Logo

std-discussion

Advanced search

Re: Pointer comparison with operators vs function objects

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 15 Sep 2025 09:58:19 -0700
On Monday, 15 September 2025 09:32:04 Pacific Daylight Time David Brown via
Std-Discussion wrote:
> As far as I can tell, this all means that it is valid for a compiler to
> use 16-bit comparisons for "near" pointers on segmented x86 when you
> write "p < q", but it would have to do a segment-aware 32-bit comparison
> for std::less(p, q) on the same architecture. Similar requirements
> would apply to other targets with multiple address spaces (like the AVR
> - though since avr-gcc does not appear to support <functional>, it is
> difficult to test!).

The implementation of std::less<void __near *> can use 16-bit comparisons and
the implementation of std::less<void __far *> can use 32-bit comparisons.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering

Received on 2025-09-15 16:58:28