C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::to_address(nullptr)

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 27 Jun 2025 12:07:42 +0100
On Fri, 27 Jun 2025 at 12:03, Phil Endecott via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Dear Experts,
>
> Is there any reason why std::to_address() cannot be used on nullptr,
> returning nullptr? Should it be extended to do so?


Why?

nullptr_t is not a pointer type and not an iterator type. The return value
is not an address, you cannot use it where a raw pointer is required (most
uses of to_address that I'm aware of involve dereferencing and/or
incrementing the pointer).

What generic code do you have where you are dealing with a std::nullptr_t
value that you need to treat equivalently to an iterator?

Received on 2025-06-27 11:08:01