3 ms·
How is the support for strings in C++? Presumably better than in C, but is it good enough when compared to other compiled languages - Go, Rust etc?
by pansa2 6y ago
How is the support for strings in C++? Presumably better than in C, but is it good enough when compared to other compiled languages - Go, Rust etc?
- __d 6y agoC++ has string support in the standard library. It doesn't have the same breadth of features as, say, Python's string class, but it's ok. See, eg. https://en.cppreference.com/w/cpp/string https://en.cppreference.com/w/cpp/string
- WalterBright 6y agoD uses "phat pointers" for strings, aka a length/pointer pair. Over the years, this has proven to be simple, efficient, and resistant to errors. It means array bounds checking can be automatically done. It enables efficient slicing. String literals also have an extra 0 appended, making it transparently easy to still pass strings to C functions like printf.
- abqexpert 6y ago>"phat pointers" I don't know if that is a typo given you normally call them "fat pointers", but they are "pretty hot and tempting".
- ansgri 6y agoIt's exceedingly verbose, but decent, if you have a recent language version and/or Boost.
- kenniskrag 6y agoHow is the support of unicode in c++?
- PaulDavisThe1st 6y agoC++ itself doesn't support it. There are libraries that provide unicode-aware handling of strings/vectors of bytes. It's not always clear that you want unicode-aware code when dealing with unicode, but there are times when it is nice to have.
- emmanueloga_ 6y agoIn my opinion, still a bit hairy, the reason something like nowide exists [1]. 1: https://www.boost.org/doc/libs/develop/libs/nowide/doc/html/index.html https://www.boost.org/doc/libs/develop/libs/nowide/doc/html/...