Re:Rust 1.63
by int_19h on Thursday August 11, 2022 @07:17PM
(#32433029)
C++ has had std::vector::at() - which checks for out-of-bounds indices - since C++98. The reason why it's not used all that much in practice is because indexing is relatively rare - most of the time, you just iterate over collections, or otherwise use iterators rather than raw indices. And there's no ability to opt into bounds checking for C++ iterators in the standard - implementations usually provide some kind of checked iterators for debug builds, but performance is such that you'd never want that enabled for release.
[ Parent
| on HN ]
Re:Rust 1.63
by tialaramex on Friday August 12, 2022 @06:33AM
(#32436584)
> indexing is relatively rare
This is also true in Rust for the same reason, arguably more true since Rust's built-in array type knows how big it is - but the observation in both languages programmers who want indexing write v[i] because that's the natural way to express what you meant, what's different isn't the frequency of need, only the language defaults.
> performance is such that you'd never want that enabled for release.
Let's make sure it's correct before we start worrying about performance
I always keep them enabled for release, performance is good enough.
Most devs should learn to use profilers.
In what implementation, and what guarantees does its debug iterators provide?
The one from your employer, Visual C++.