C++ Logo

sg20

Advanced search

Re: [isocpp-ext] namespace composition

From: Daniel Ruoso <daniel_at_[hidden]>
Date: Mon, 1 May 2023 16:22:53 -0400
Em seg., 1 de mai. de 2023 às 16:09, Bjarne Stroustrup via Ext
<ext_at_[hidden]> escreveu:
> They understand the notion of indexing. With Python they understand the notion of 0-based indexing. Matlab (quite quite unfortunately) has 1-based indexing. However, I have found students don’t have a problem with 0-based indexing. Usually.
> They understand the notion of out of bounds access, since that will have been reported when they have made that error in Python in Matlab
> An out of bounds error will be natural and even expected

I hate to be the one doing the "this needs to be a feature in the std
library" thing, but...

It seems to me the best solution would be a new parameter for the
vector template with the "bounds checking policy", which would default
to "no bound checks", but that you could explicitly opt-in for
"terminate-if-out-of-bounds" policy.

Honestly, I can see many cases that are not absolutely
performance-critical where changing this policy would be a fairly
reasonable thing to do. Or at least a
"terminate-if-out-of-bouds-if-ndebug".

daniel

Received on 2023-05-01 20:23:05