C++ Logo

std-discussion

Advanced search

Re: Opt-In Compile Time Bounds Checking

From: Phil <std-discussion_at_[hidden]>
Date: Sun, 30 Jul 2023 19:28:59 +0200
> what part confused you

Actually none - I just don’t see such a very specific compiler-related feature
making it into the standard library, since it is already possible to either add
safe wrappers or use a special and safe library implementation (e.g. libstdc++
with debug mode enabled does bounds checking for the subscript operator
for std::span).

Your proposal would probably be a very nice-to-have feature, but mandating it to every
compiler implementation via the standard is in my view probably "to much“.

Additionally, there is std::span with static extent that could approximate your proposed
functionality with a little helper wrapper, even at compile time. You can find a more
or less incomplete example implementation here: https://godbolt.org/z/4qozsb8rr <https://godbolt.org/z/4qozsb8rr>

KR
Chilippso

Received on 2023-07-30 17:29:04