Original Post
Hi,
I'm currently playing around with regsitering behaviour for implicit conversions. I tested this with the string to int conversion. But I need some clarification here, because I encountered a problem:
I regsitered the behavior like it is in the manual (except that I used the implicit version), I'm using the stdstring addon:
Then I registered a C++ testFunction(const int&) :
My test code in the script file looks like this:
In the second case I get the error that there's no testFunction(string), candiates are testFunction(int&).
Does the conversion only work in operations? How do I manage it to also have it working in function calls (pass a string to a function that needs an int, for example)?
I'm currently playing around with regsitering behaviour for implicit conversions. I tested this with the string to int conversion. But I need some clarification here, because I encountered a problem:
I regsitered the behavior like it is in the manual (except that I used the implicit version), I'm using the stdstring addon:
r = engine->RegisterObjectBehaviour("string", asBEHAVE_IMPLICIT_VALUE_CAST, "int f() const", asFUNCTION(stringToInt), asCALL_CDECL_OBJLAST);Then I registered a C++ testFunction(const int&) :
void testFunction(const int&)My test code in the script file looks like this:
string testStr = "4";
//this works
testFunction(1 * testStr)
//this DON'T work
testFunction(testStr)In the second case I get the error that there's no testFunction(string), candiates are testFunction(int&).
Does the conversion only work in operations? How do I manage it to also have it working in function calls (pass a string to a function that needs an int, for example)?