4 ms·
I agree with the framing here, and I agree a small bit of syntax would go a long way. FWIW, you will see a class called StringPiece copied all over a lot of op
by chubot 8y ago
I agree with the framing here, and I agree a small bit of syntax would go a long way.
FWIW, you will see a class called StringPiece copied all over a lot of open source Google projects, including Chrome, Ninja, RE2, probably Android, etc.
That is essentially a pointer-length pair. I agree it would be nice to have a dedicated syntax for it, and not a class that everybody has to copy around.
C++ 17 names this string_view (long overdue!)
I just Googled and apparently there was a problem with array_view ? That's a shame.
https://www.reddit.com/r/cpp/comments/5ya5pe/whatever_happened_to_array_view/ https://www.reddit.com/r/cpp/comments/5ya5pe/whatever_happen...
- WalterBright 8y agoThe trouble with a library type is the compiler is not aware of it and cannot make semantic use of it.
- slededit 8y agoThe compiler does this with other “library” functions like malloc and printf. There’s no reason a compiler couldn’t convert to a built in for this new type.
- WalterBright 8y agoC doesn't have member functions and doesn't do implicit conversions to/from struct types.
- slededit 8y agoThat’s obvious and also completely unrelated to what I was saying. The optimizer can convert a library type to a builtin type if it still behaves as specified in the standard.
- WalterBright 8y agoC isn't powerful enough to have the library type behave as desired (with implicit conversions, etc.).
- gpderetta 8y agoaye, if it is defined in the same standard, there is really no technical difference between a language feature and a library feature.