Skip to content

PL251 22.07.3.2 [span.cons] span should be constructible from a contiguous range P1394 #247

@wg21bot

Description

@wg21bot

C++20 introduced both std::contiguous_range and std::continous_iterator concepts, that are the generalization of the pointer to continuous sequence of objects, and type erased view for such ranges in form of std::span.
However, these two features are not integrated together, as consequence std::span cannot be directly constructed from ranges that models std::contiguous_range and std::sized_range, nor from the pair of std::continous_iterator:

std::vector v{...};
std::span s = v; // OK
std::span s = v | std::take_view(10); // ILL-FORMED

std::span s(std::to_address(v.begin()), 2); //OK
std::span s(std::to_address(v.begin()), std::to_address(v.begin() + 2)); //OK
std::span s(v.begin(), 2); // IMPLEMENTATION-DEFINED
std::span s(v.begin(), .begin() + 2); // IMPLEMENTATION-DEFINED

Proposed change:
Adopt P1394R3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions