Special Interest Group on C++
Teaching, learning, and practicing contemporary C++
#cpp #cplusplus #education #teaching #EduSky
Moderated by @smurthys.bsky.social
- std::string_view has 3 modifiers: remove_prefix, remove_suffix, swap. Working with immutable strings, unless you need a modifier, use const string view. (Anecdotally, most string views don't use modifiers.) en.cppreference.com/w/cpp/string/basic_… #cpp #cplusplus #programming
-
View full thread@sidhin.bsky.social Just following up (mostly as clarification): > It’s still const reference right char s[] = "abc"; std::string_view sv(s); There are no const refs here. s is not modifiable via sv purely by virtue of SV API. However, sv itself is modifiable due to SV API.
- Agreed. I meant const ref in the semantic sense. For the intent of string_view, passing it around as a reference didn’t make sense to me.
- [Not loaded yet]
- [Not loaded yet]