C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D3724 Integer division

From: Jan Schultke <janschultke_at_[hidden]>
Date: Sat, 31 May 2025 06:49:41 +0200
> Why were the previous proposals abandoned?
> Why do those same reasons not apply now?
> What has changed?

I'm pretty sure it's just author inactivity.

> Architecture dependence. Yes, we can make it implementors’ problem,
> but if many fail to provide efficient implementations ––since these are likely less common
> compared to other hardware-dependent functions––then people won’t use them.
> Perhaps this is one of the reasons why previous proposals were abandoned?

This is a total non-issue. Every major architecture provides "native"
division as a truncating division, which matches the semantics of the
division operator in C++. Changing the rounding mode is then always
adjusting the quotient by at most one. See
https://isocpp.org/files/papers/P3724R0.html#implementation

I don't even think you'd substantially benefit from intrinsics in any
of these functions. They're as portable as they can get.

> This is really a C thing.
> There is nothing in this that C++ can do better than C.
> If standardized in C, it will have a wider user base too,
> and can be imported to C++ naturally.

C is a separate language, not a ship vehicle for C++ features. You
could just as well argue that it's a JavaScript or Rust thing.

I'm not 100% sure that WG14 would want it anyway precisely because the
implementation is too portable, and you could theoretically just copy
and paste it into your project.

Received on 2025-05-31 04:49:59