einpoklum
einpoklum

Reputation: 131675

Why doesn't libstdc++ have span::span(Container&)?

According to cppreference, in C++20, std::span is supposed to be constructible using container references:

template <class Container>
constexpr span(Container& cont);
template <class Container>
constexpr span(const Container& cont);

but in the master branch of libstdc++'s span file (as of Jan 18th 2020), I don't see these constructors. I do see a constructor taking a Range&& - is that a sufficient replacement? Or - am I missing something?

Upvotes: 0

Views: 664

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473667

When dealing with C++ features that are in flux (such as for standards that aren't done yet), it's best to go to the source rather than to secondary documentation like Cppreference.

At the time of this writing, the working draft of the standard does what libstdc++ says: a single overload which can take a && of a contiguous range. The restrictions on this function are similar enough to those from Cppreference that they're basically different ways of saying the same thing, but libstdc++ is implementing the standard as it currently exists.

Upvotes: 3

Related Questions