Title
Unnecessary and confusing "empty span" wording
Status
c++20
Section
[span.cons]
Submitter
Stephan T. Lavavej

Created on 2018-04-12.00:00:00 last changed 37 months ago

Messages

Date: 2018-06-12.01:05:16

Proposed resolution:

This wording is relative to N4741.

  1. Edit [span.cons] as indicated:

    constexpr span() noexcept;
    

    -1- Effects: Constructs an empty span.

    -2- Postconditions: size() == 0 && data() == nullptr.

    -3- Remarks: This constructor shall not participate in overload resolution unless Extent <= 0 is true.

    constexpr span(pointer ptr, index_type count);
    

    -4- Requires: [ptr, ptr + count) shall be a valid range. If extent is not equal to dynamic_extent, then count shall be equal to extent.

    -5- Effects: Constructs a span that is a view over the range [ptr, ptr + count). If count is 0 then an empty span is constructed.

    -6- Postconditions: size() == count && data() == ptr.

    -?- Throws: Nothing.

    constexpr span(pointer first, pointer last);
    

    -7- Requires: [first, last) shall be a valid range. If extent is not equal to dynamic_extent, then last - first shall be equal to extent.

    -8- Effects: Constructs a span that is a view over the range [first, last). If last - first == 0 then an empty span is constructed.

    -9- Postconditions: size() == last - first && data() == first.

    -10- Throws: Nothing.

Date: 2018-06-12.01:05:16

[ 2018-06 Rapperswil: Adopted ]

Date: 2018-04-24.00:00:00

[ 2018-04-24 Moved to Tentatively Ready after 6 positive votes on c++std-lib. ]

Date: 2018-04-12.00:00:00

The span constructors have wording relics that mention an "empty span". It's unnecessary (the behavior is fully specified by the postconditions), but I left it there because I thought it was harmless. It was later pointed out to me that this is actually confusing. Talking about an "empty span" implies that there's just one such thing, but span permits empty() to be true while data() can vary (being null or non-null). (This behavior is very useful; consider how equal_range() behaves.)

To avoid confusion, the "empty span" wording should simply be removed, leaving the constructor behavior unchanged. Editorially, there's also a missing paragraph number.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-06-12 01:05:16adminsetmessages: + msg9891
2018-06-12 01:05:16adminsetstatus: voting -> wp
2018-05-06 19:23:13adminsetstatus: ready -> voting
2018-05-05 12:14:09adminsetmessages: + msg9832
2018-05-05 12:14:09adminsetstatus: new -> ready
2018-04-22 14:31:19adminsetmessages: + msg9819
2018-04-12 00:00:00admincreate