Title
Integer-class conversions should not throw
Status
c++20
Section
[iterator.concept.winc]
Submitter
Casey Carter

Created on 2020-01-07.00:00:00 last changed 46 months ago

Messages

Date: 2020-01-25.14:35:08

Proposed resolution:

This wording is relative to N4842.

  1. Modify [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- AllExpressions of integer-class types are explicitly convertible to allany integral types and. Expressions of integral type are both implicitly and explicitly convertible from all integral typesto any integer-class type. Conversions between integral and integer-class types do not exit via an exception.

    -7- AllExpressions 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.

Date: 2020-01-25.00:00:00

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

Date: 2020-01-15.00:00:00

[ 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, [span.cons] p9 depends on the no-throw-guarantee of integer-class conversions to integral types.

Date: 2020-01-07.00:00:00

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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-14 06:37:09adminsetstatus: ready -> immediate
2020-01-25 14:35:08adminsetmessages: + msg10961
2020-01-25 14:35:08adminsetstatus: new -> ready
2020-01-14 13:40:39adminsetmessages: + msg10935
2020-01-14 13:28:51adminsetmessages: + msg10933
2020-01-07 00:00:00admincreate