C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Why some standard functions having a wide contract are not marked as conditionally noexcept?

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Mon, 29 Aug 2022 10:36:34 -0400
On Mon, Aug 29, 2022 at 10:22 AM blacktea hamburger via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I have noticed that some standard functions having a wide contract such
> as functions in [iterator.range] <https://eel.is/c++draft/iterator.range>
> conditionally do not throw exceptions, but they are not marked as
> conditionally noexcept.
>
>
> It is described in N3279 <https://wg21.link/N3279>: [2011]
>
Note that there's also a later paper by Nico Josuttis [2018]:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0884r0.pdf
I don't think any differences are relevant to your question, but just FYI.


> But there are some functions that do not obey this guideline such as
> std::cbegin. And I did not find a reason in this paper.
>
Can you clarify what you mean? Looking at cppreference,
https://en.cppreference.com/w/cpp/iterator/begin
I see that
(1) std::cbegin in fact has a *narrow* contract; it simply delegates to
std::begin(x), which is allowed to throw.
(2) std::cbegin *is* marked conditionally noexcept.

So, I'm not sure what you're asking.

–Arthur

Received on 2022-08-29 14:36:48