I have a function that has takes some objects by value.
sendEvent(const uint id, EventArg = EventArg(), EventArg = EventArg() .... );
EventArg has constructors for all the available types it can handle, including string.
However if I pass a string inline
sendEvent(123, "string", 1.234f);
// Generates error.
No matching signatures to 'EventManager::sendInstantEvent(const uint, const string, const float)'
// However this works.
string stringVar = "foo";
sendEvent(123, stringVar, floatVar);
EventArg is registered as a value type and has ctors for string (I tried both ref and pass by value).
I assume this might have something todo with the string addon, its not a big issue but I would like to know why this might be happening.
The Registrations
.addCtor("void f()", asFUNCTION(EventArgCtor), asCALL_CDECL_OBJLAST)
//.addCtor("void f(const string)", asFUNCTION(EventArgString2Ctor),asCALL_CDECL_OBJLAST)
.addCtor("void f(const string &in)", asFUNCTION(EventArgStringCtor), asCALL_CDECL_OBJLAST)
.addCtor("void f(const float)", asFUNCTION(EventArgFloatCtor), asCALL_CDECL_OBJLAST)
.addCtor("void f(const uint)", asFUNCTION(EventArgUInt32Ctor), asCALL_CDECL_OBJLAST)
.addCtor("void f(const int)", asFUNCTION(EventArgInt32Ctor), asCALL_CDECL_OBJLAST)
.addCtor("void f(const EventArg &in)", asFUNCTION(EventArgCCtor), asCALL_CDECL_OBJLAST)
.addDtor("void f()", asFUNCTION(EventArgDtor), asCALL_CDECL_OBJLAST)
.addMethod("void sendInstantEvent(const uint, EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg(), EventArg = EventArg())", asMETHODPR(CaffSys::EventManager, sendInstantEvent, (const CaffSys::EventID id, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg, CaffSys::EventArg), void), asCALL_THISCALL)
Any ideas?
Edit
I actually get this with any type that I've added I just tried to add Vec3 which is a value type and I get the same message.
Further Edit
Hmm I can't remember why I opted for pass by type, but pass by ref (including Vec3/string) yeilds a Bad Access crash in asCContext::ExecuteNext().
I should mention that EventArg is basically (but not) boost::variant. Variant<std::nullptr_t, float, int, uint, Vec3, std::string>