C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Let spaceship return an int

From: David Brown <david_at_[hidden]>
Date: Mon, 25 Sep 2023 15:53:20 +0200
On 25/09/2023 13:53, Lénárd Szolnoki via Std-Proposals wrote:
> On Mon, 2023-09-25 at 11:08 +0200, David Brown via Std-Proposals wrote:

>> It is /way/ older than that - preceding C++ itself, and preceding
>> standardised C. K&R C had the "sizeof" operator return the type
>> "size_t", defined in <stdlib.h> and <stddef.h>. So having language
>> features rely on definitions from standard library headers is a 50
>> year
>> old tradition, not merely two decades old!
>>
>>
>
> One major difference compared to `<=>` is that `sizeof` can be used
> without including `<stddef.h>`.
>
> I see some merit in not requiring includes for language constructs like
> `1 <=> 2` or `{1, 2}`, similarly how it's not needed for `sizeof`.
>

I can't say I am particularly bothered about it - the standard library
(its specifications, rather than particular implementations) have always
been tightly tied to the language in C++, just as in C before it. We
could quibble about the details of how usable something is with or
without including headers, but the principle has been around for perhaps
50 years. (If you want a more C++-specific example, try the "new"
operator. You can use in some ways without headers - for other things,
you need to #include <new>.)

Received on 2023-09-25 13:53:32