From what I can gather, gsl::string_span and std::string_view seem to have essentially the same rationale for use. Is that indeed the case? If so, are they effectively identical? If not - how do they differ?
Related question: What purpose does `gsl::string_span` aim at?
A rather obvious difference of how they are available, but I'll say it since it is significant:
gsl::string_spanrequires the use of a third party library, whilestd::string_viewis a standard C++ type. On the other hand, the library providinggsl::string_spansupports C++14, whilestd::string_viewrequires C++17.A major design difference is that
std::string_viewis a const view to the string, and doesn't provide any way of modifying the viewed string, whilegsl::string_spandoes allow non-const access. For example:Also note how
gsl::string_spanallows non-const access even when the span itself is const. in other words,gsl::string_spandoes not propagate constness. This is the same asstd::spanandgsl::span.