tcbrindle / NanoRange

Range-based goodness for C++17
Boost Software License 1.0
358 stars 28 forks source link

Add std::span implementation #80

Open tcbrindle opened 5 years ago

tcbrindle commented 5 years ago

std::span is a really weird thing, behaving like a view of a contiguous range (except that it sometimes doesn't actually model the view concept), but built using C++17-era idioms rather than the shiny new ranges stuff, and living in a completely different section of the standard.

This implementation of span is based on my own from https://github.com/tcbrindle/span, but simplified by assuming C++17 support and removing all the custom bounds-checking macro stuff -- this implementation just use uses plain old assert(). I believe it to be conforming to the current (pre-Belfast) working draft.

The tests are taken (as usual) from CMCSTL2, which in turn took them from the Microsoft GSL span implementation. I have modified them to remove/comment out various things which fail -- correctly, I think? -- due to the numerous changes span has undergone during its many visits to L(E)WG.