Did toCString() get removed since this posting was made? I don’t see it anywhere.
I’m attempting to call a library that uses a lot of const std::string & as parameters throughout the API, but I have a bunch of juce::String objects in my code. Trying to pass in my juce::String objects returns the following compiler error:
[color=#BF0000]error: invalid initialization of reference of type ‘const string& {aka const std::basic_string&}’ from expression of type ‘juce::String’[/color]
So after a bit of searching, I found getCharPointer() which I figured would work since std::string can be constructed from a char*. But,
[color=#BF0000]error: invalid initialization of reference of type ‘const string& {aka const std::basic_string&}’ from expression of type ‘const CharPointerType {aka const juce::CharPointer_UTF8}’
[/color]
Looking up CharPointer_UTF8, I see it is a class, not a typedef. But it does have an operator char*, so now I’m stuck doing this with all my parameters:
foo( std::string(a.getCharPointer()), std::string(b.getCharPointer()), std::string(c.getCharPointer()) );
What I’d rather do if possible is:
foo( a, b, c );
If that’s not possible, my next choice would be something along these lines:
foo( a.toCString(), b.toCString(), c.toCString() );
foo( a.c_str(), b.c_str(), c.c_str() );
foo( a.str(), b.str(), c.str() );
This is what led me to this post on the forum where Jules referenced toCString()…which I cannot find anywhere.
Any chance we can make conversion easier/automatic between juce::String and std::string?
Thanks!