I am aware that std::string_view
is a non-owning reference to a string and the major differences between std::string_view
and std::string
are
Now, Why std::string_view is not applicable to other types ? or why this implementation is specific ONLY to std::string
?
For Example : if we have similar <T>generic_view
where T
can be of any type including custom types.
With this, instead of using const T&
as function argument, <T>generic_view
can be used. And also other advantages of std::string_view
will be useful like Allocation, Copying etc..
There is a proposed non-owning type for contiguous collections of arbitrary objects.
std::span
has been approved for C++20. (An implementation is available now, as gsl::span
.)
It behaves like C++17's std::string_view
, but the interface provides general container-like access, and doesn't restrict data access to const
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.