Make JUCE string classes std::string_view compatible if C++17 is used

While using more and more C++17, I’d find it extremely handy if juce::String, juce::StringRef and juce::Identifier would offer explicit or implicit std::string_view conversion functions/operators. Would you consider adding such member functions, wrapped into JUCE_CXX17_IS_AVAILABLE guards? Possibly, StringRef could just become a std:: string_view wrapper in the long run?

Bumping, as I just ran into the need for something like that too.

Now that JUCE has C++ 17 as minimum C++ standard for a while, I’d like to bring this up again.

Especially constexpr std::string_view instances proved to be a very useful thing, used quite a lot in our code in the meantime. At the moment, additional constructors and conversion operators in the string classes are one of the biggest modifications in our in-house JUCE fork and I’d love to get rid of that in the long run.

4 Likes

bump, would need this too