I was supprised to find I couldn’t construct a juce::StringRef from a std::string_view, or vice versa. We can implicity construct a juce::String from a std::string, so the same for juce::StringRef and std::string_view seems reasonable?
For context I was hoping to do something like this:
using namespace std::literals;
static constexpr auto someJsonFile = R"({"foo": "bar"})"sv;
const auto data = juce::JSON::fromString(someJsonFile);
Yeah, that’s one of my biggest feature requests for more than four years now
I talked about that to the JUCE team at ADC 2024 and they said they wanted to look into that but apparently that didn‘t make it to the top of the priority list in the meantime.
We implemented the feature on our own in house JUCE fork, but especially since so much code on our side has been written in the last four years relying on that implicit conversion I just hope that whenever this is added officially the JUCE implementation will also be based on implicit conversion constructors.
3 Likes
