Re:Str: Yet another string library for C language
by pansa2 on Wednesday November 25, 2020 @05:15PM
(#25214883)
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?
[ Parent
| on HN ]
Re:Str: Yet another string library for C language
by WalterBright on Wednesday November 25, 2020 @05:36PM
(#25215064)
D 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.
Re:Str: Yet another string library for C language
by abqexpert on Wednesday November 25, 2020 @05:40PM
(#25215094)
>"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".
Re:Str: Yet another string library for C language
by __d on Wednesday November 25, 2020 @05:35PM
(#25215038)
C++ 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.
Re:Str: Yet another string library for C language
by emmanueloga_ on Thursday November 26, 2020 @02:40AM
(#25217803)
In 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/...
Re:Str: Yet another string library for C language
by kenniskrag on Wednesday November 25, 2020 @06:29PM
(#25215464)
How is the support of unicode in c++?
Re:Str: Yet another string library for C language
by PaulDavisThe1st on Wednesday November 25, 2020 @11:15PM
(#25216747)
C++ 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.