C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] function at() for span<> that throws exception on out-of-range, like vector and array ::at()
From: Lyberta (lyberta_at_[hidden])
Date: 2019-11-30 10:54:00


John McFarlane via Std-Proposals:
> Sanitizing user input sounds like something that is best served by explicit
> logic. I certainly don't think that UI is any concern of containers.

Explicit logic such as

if (i >= std::size(whatever))
{
        throw std::out_of_range{"Invalid index."};
}

How is that better than calling at()?

And without it developers will have write their own version of std::at()
anyway. I have my own versions of std::insert() and std::emplace()
already. By users I meant users of the library.




STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups