This is very interesting. precice::string_view aka precice::span<const char> is constructible from essential everything contiguous you can throw at it. CStrings, arrays, literals, std::string, std::vector, …
The ambiguity is surprising though as it hasn’t come up in testing.
Some questions to clarify this:
Which compiler at which version are you using?
What is the complete type of the string you are passing to getMeshDimensions()?
Can you share the function signature of whatever provides particpantName?
Hi @fsimonis,
thanks for your answer. I am using gcc 11 on an Ubuntu machine with -std=c++17. It turned out that the problem was how I was reading the string from the configuration file (a json file).
I am using something like document["config-file"].GetString() from rapidjson and I was somehow sure that it returned a std::string. It actually returns const Ch*… which Participant or getMeshDimensions don’t like. I made a simple intermediate step like std::string configName = document["config-file"].GetString() and passd configName to Participant to solve everything.
Thanks.
Claudio
So, this should still return const char*, which is supported by precice::span<const char>.
Hence, the ambiguity seems to be a real issue.
Could you please upload the full error message so that I can try to figure this out? In case it is too sensitive, feel free to mail it to me.
Also, which version of rapidjson are you using?
An interesting step to try is to try to convert the result to const char* like this:
but, if I compile it outside the IDE, there is no trace of the issue above. So maybe it is some semantic check that the IDE is not able to resolve, not a real issue.
Anyway