Another benefit of using span
is that it simplifies debugging.
If you use ptr
+size
, by default you can only see the first element pointed to by ptr
in the debugger.
Using span
, you can directly view all the elements within the range without having to manually enter anything in the debugger yourself.