ambigous resolution on string types

scaronscaron Fabric for Houdini Posts: 171

Me again...

Arnold has its own string type now (AtString) moving forward it is the option to use but in the mean time the API has both versions. So I want to support both...

the error

Arnold.test.kl:103:24: error: ambiguous resolution for function AiNode(String)
Arnold.test.kl:103:24: Candidates are:
Arnold.test.kl:103:24:   function AtNode AiNode(AtString)
Arnold.test.kl:103:24:   function AtNode AiNode(CxxCharConstPtr)

the code

AtNode mesh = AiNode("polymesh");

So, to fix this I can make an explicit cast to AtString, which will actually be required in Arnold 5...

AtNode mesh = AiNode(AtString("polymesh"));

optionally I can get the c_str version of the KL String.

AtNode mesh = AiNode("polymesh".data());

But if the KL String is a const char *, why doesn't the first one work? What is the best way to handle cpp functions with const char * arguments so the user doesn't have to call .data() or c_str()?


  • scaronscaron Fabric for Houdini Posts: 171

    I fixed this with a very simply by NOT adding the const char * version of the function. Just having the AtString version and then I can use KL Strings and a AtString is constructed automatically.

Sign In or Register to comment.