News for hackers. Stuff that matters.
Re:Abseil: C++ Common Libraries by duneroadrunner on Wednesday September 27, 2017 @07:26AM (#15346683)
> "- Span For when you want to take an array or a vector."

> How's this different from taking a pair of iterators?

Safety and (a little) convenience. If your function takes a pair of iterators, there's no way to ensure (at compile-time anyway) that both iterators are even pointing into the same array/vector. Also, spans can ensure, with bounds-checking, that only elements within a specified sub-range can be accessed.

Such bounds-enforcement is particularly important in cases like, for example, SaferCPlusPlus' "TRASectionSplitter", which is a data type that allows you to partition an array/vector/whatever into subsections that can each be safely accessed/modified concurrently from different threads. ("TRASectionSplitter" is not yet documented, but for those interested, example code can be found here[1].)

[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus/blob/master...

There are no comments on this comment yet.