2 ms·
Pedantically, C++ just needs std::string_view for contains(), not a full std::string. No need for an allocator. https://en.cppreference.com/w/cpp/string/basic
by loeg 1y ago
Pedantically, C++ just needs std::string_view for contains(), not a full std::string. No need for an allocator.
https://en.cppreference.com/w/cpp/string/basic_string_view/contains.html https://en.cppreference.com/w/cpp/string/basic_string_view/c...
With the string literal suffixes, I don't think it's all that different ("hello"sv.contains(username)). Yes, yes, for legacy reasons bare "" is the C-style string, but you can get a string_view string easily enough.
- tialaramex 1y agoI agree that it's not "all that different". It's just that years later what C++ offers is slightly worse while having more awkward syntax. Exactly like the article topic. Iterating over your maybe type was IMO an obvious thing you'd want, but it took C++ a decade to provide this behaviour in a slightly awkward way. And likewise for their maybe reference, which C++ 26 also finally lands. The original discussion papers for std::optional explain the core ideas for std::optional<T&> but apparently the possibility that it's an assign through type, a thing nobody has ever wanted, and no other language has ever provided - was so important that it blocked all work on this idea for about a decade.