5 ms·
Tip #1 appears on the surface to be about C++17's std::string_view, but many shops had something similar to string_view for a decade or more before C++ made it
by jzwinck 9y ago
Tip #1 appears on the surface to be about C++17's std::string_view, but many shops had something similar to string_view for a decade or more before C++ made it official. The tips are not presented in their original form; edits have been made (as per the linked page). I think Google had something like string_view by 2009 at the latest, using C++03 compilers.
- humanrebar 9y agoLinks to illustrate: https://github.com/boostorg/utility/blob/develop/include/boost/utility/string_ref.hpp https://github.com/boostorg/utility/blob/develop/include/boo... This proposal references Google and LLVM implementations: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n344... Looks like the LLVM implementation goes back to at least 2009: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ADT/StringRef.h https://github.com/llvm-mirror/llvm/blob/master/include/llvm...
- dogruck 9y agoYeah, discussing the origins of string_view is like talking about who invented base-two numbering. :-)
- humanrebar 9y agoYes. It is a small step from the well-worn convention to pass each char* around with its length.
- signa11 9y ago> Yes. It is a small step from the well-worn convention to pass each char* around with its length. kind of surprising to note that implicit 'string_view' conversions are now regarded as a good thing? on a side note, the language is _complicated_, and shows no signs of stopping ! 3 articles on move/copy ctor's and only one that applies to programming in general.
- fooker 9y ago>I think Google had something like string_view by 2009 at the latest, using C++03 compilers. Yeah, StringPiece http://google.github.io/google-api-cpp-client/latest/doxygen/stringpiece_8h_source.html http://google.github.io/google-api-cpp-client/latest/doxygen...
- apaprocki 9y agoHere's Bloomberg's version: https://bloomberg.github.io/bde/group__bslstl__stringref.html https://bloomberg.github.io/bde/group__bslstl__stringref.htm...
- TwoBit 9y agoEASTL had it at least as early as 2005.
- ksherlock 9y agoAnd they also claim string_views can be constructed from a std::string. That's true of their implementation and it's true of the TS string_view but it was removed from the c++17 string_view.