Difference between std::basic_string_view<T> and std::span<T>

  c++, guideline-support-library, string-view

I’m parsing a binary network data and i would like to make the process as allocation-less as possible. But now i realized there are 2 very simmilar concepts that are probably both good enough for my case, and those are std::basic_string_view<T> and std::span<T>.

So i was wondering. What are the differences between these 2 and are there any advantages using one over the other? One obvious difference is the availability, basic_string_view is already in C++17 while span is C++20 (but you can use the one in ‘Guidelines Support Library’ for older standards). But is there anything else? It should, because otherwise they wouldn’t both make it into the standard.

Source: Windows Questions C++