How do you safely deal with range.front?
aliak
something at something.com
Sun Dec 31 13:14:10 UTC 2017
On Sunday, 31 December 2017 at 01:03:17 UTC, Tony wrote:
> For me, front() should throw a pre-defined exception when
> called on an empty range in order to eliminate undefined
> behavior. It does take some time to make a check, but D does
> array bounds checking by default. Ideally the front() check
> could be turned off somehow ("-boundschecks=off") by the user
> for those who want maximum speed, but I guess there is no way
> to do that when using pre-compiled functions in a library.
That sounds like a good idea. Wouldn't the same apply to array
bounds checking for precompiled functions though?
Also, is going out of array bounds well defined behavior in D
even with boundscheck off? And any links to docs on UB in D?
More information about the Digitalmars-d-learn
mailing list