I have a C++ app with deep, refined logic developed over many years. Sadly, it combines all manner of different types of strings: std::string, C-strings, Pascal strings, and OS/platform-specific strings. Plus, each of these string types often use various encodings.
I've created a wrapper class, WBString, that holds an std::string, and can construct from nearly a dozen types of my pre-existing strings.
However, I'd like the underlying implementation to be able to use std::string_view. If I'm constructing from a source string that's already const, an std::string_view could save all manner of behind-the-scenes construction when initializing and passing my class around.
It SEEMS as if C++17's std::string_view could have simply attempted a better integration with std::string, but I guess that could break existing apps.
I could see numerous ways of doing this:
1) Templatizing my WBString class to hold an std::string for non-const functions and a separate WBStringView for const strings;
2) Create a base class with no data and two separate inherited classes: WBString / WBStringView;
3) Have a single class that incorporates BOTH std::string and std::string_view as data members;
4) Keep a single void* data member which could be either type.
Anyone had to confront this issue before?