C++ Logo

std-proposals

Advanced search

Re: [std-proposals] PR: std::allocator<T>::allocate is not freestanding

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 2 Sep 2023 17:36:14 -0400
On Sat, Sep 2, 2023 at 3:22 PM trtaab trtaab via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Currently there is no way to allocate memory at constexpr context in freestanding environment. This desperately needs a fix.
>
>
>
> N4958 does not mark std::allocator<T> as freestanding so there is no way to allocate memory in freestanding.
>
>
>
> This is std::addressof situation 2.0

Not really.

`addressof` is something that doesn't require any real language
support; it's just a trick to get around an unfortunate language
feature. It *should* be required for freestanding implementations.

The ability to allocate memory at compile-time requires language
support. As such, *requiring* all freestanding implementations to
support it is a rather big ask.

It should also be noted that freestanding requirements are just that:
requirements. Freestanding implementations have to implement those
things, but they can *choose* to implement more of the standard
library than the bare minimum that is required. So if your
freestanding implementation doesn't offer compile-time allocation,
maybe complaining to the implementers would be better.

Received on 2023-09-02 21:36:26