刚才才发现 std::span 没有 at 成员函数。

查了一下,原因是:

I actually proposed at() for std::span as part of P1024r0. It was soundly defeated in LEWG, 0|0|4|4|5.

I wasn’t there for the meeting, but from what I understand the feeling was that contracts (which at that time seemed highly likely for ‘20) were a better way to go for bounds checking, and that we should not be throwing exceptions for programmer errors like out-of-bounds access.

https://www.reddit.com/r/cpp/comments/djqdu2/why_is_stdspan_is_missing_at/ From the cpp community on Reddit
 
 
Back to Top