Date: Sun, 19 Apr 2020 14:32:05 +0300
On Sun, 19 Apr 2020 at 14:18, Roman Babinicz via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
>
> I really do not like how it is NOT a drop in replacement for other
> containers (or const-reference since it is not-owning of course).
>
> Getting a [const-reference] to container and taking element from them is
> very common use case for me, and I often use .at() .
>
> This means c++20's std::span is not usable for me and I have to write
> own span.
Yeah well,
template <class T> struct my_span : std::span<T>
{
using std::span<T>::span;
T& at(int index) {if (index < 0 || index >= this->size()) throw
std::logic_error("no, sir"); return (*this)[index]; }
};
<std-proposals_at_[hidden]> wrote:
>
>
> I really do not like how it is NOT a drop in replacement for other
> containers (or const-reference since it is not-owning of course).
>
> Getting a [const-reference] to container and taking element from them is
> very common use case for me, and I often use .at() .
>
> This means c++20's std::span is not usable for me and I have to write
> own span.
Yeah well,
template <class T> struct my_span : std::span<T>
{
using std::span<T>::span;
T& at(int index) {if (index < 0 || index >= this->size()) throw
std::logic_error("no, sir"); return (*this)[index]; }
};
Received on 2020-04-19 06:35:14