C++ Logo

std-proposals

Advanced search

Re: [std-proposals] 回复: Proposal: Integer division/remainder/division-remainder functions with exception throwing behavior

From: Jan Schultke <janschultke_at_[hidden]>
Date: Wed, 30 Apr 2025 19:26:27 +0200
1. Because the divisor is almost never zero, this is a prime candidate for
branch prediction. Especially when you use [[unlikely]] like I've shown,
the cost of that branch is essentially zero. Come back with some hard data
that shows the performance impact of these branches.

2. You can do that by writing a function with an if statement yourself, if
you need division by zero to throw. You're arguing for putting this into
the standard, and usually that's not something we do for something the user
can trivially implement themselves.

Received on 2025-04-30 17:26:41