This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

### 3367. Integer-class conversions should not throw

Section: 23.3.4.4 [iterator.concept.winc] Status: C++20 Submitter: Casey Carter Opened: 2020-01-07 Last modified: 2021-02-25

Priority: 0

View all other issues in [iterator.concept.winc].

View all issues with C++20 status.

Discussion:

It's widely established that neither conversions of integral types to `bool` nor conversions between different integral types throw exceptions. These properties are crucial to supporting exception guarantees in algorithms, containers, and other uses of iterators and their difference types. Integer-class types must provide the same guarantees to support the same use cases as do integer types.

[2020-01-14; Daniel comments]

1. We probably need to think about providing the stronger guarantee that all integer-class operations are also `noexcept` in addition to the guarantee that they do not throw any exceptions.

2. The fixed wording in LWG 3358, 22.7.3.2 [span.cons] p9 depends on the no-throw-guarantee of integer-class conversions to integral types.

[2020-01-25 Status set to Tentatively Ready after five positive votes on the reflector.]

Proposed resolution:

This wording is relative to N4842.

1. Modify 23.3.4.4 [iterator.concept.winc] as indicated:

   > [Drafting note: There's a bit of drive-by editing here to change occurrences of the meaningless "type is convertible to type" to "expression is convertible to type". Paragraph 7 only has drive-by edits. ]

   > -6- All Expressions of integer-class types are explicitly convertible to all any integral types and. Expressions of integral type are both implicitly and explicitly convertible from all integral types to any integer-class type. Conversions between integral and integer-class types do not exit via an exception.

   > -7- All Expressions `E` of integer-class types `I` are contextually convertible to `bool` as if by `bool(aE != I(0))`, where `a` is an instance of the integral-class type `I`.