During reading Microsoft's implementation of Cpp Core Guidelines, I run across two questions:
gsl::string_span provided where gsl::span already works well?gsl::zstring_span provided where std::string is already guaranteed to be null-terminated since C++11?Any illustrating situations will be highly appreciated.
span("Hi") is {'H', 'i', '\0'} whereas string_span("Hi") is {'H', 'i'}. string_span checks for the terminating null character and does not include it in the span.string is owning and spans are not, so comparing them is comparing apples and oranges. zstring_span is a span with the constraint that the last character is a null character. Neither span nor string_span have that constraint.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With