Is the following assignment operator correct?
I am mainly wondering about if rhs should be released? Since its a const object I can't, Or does the fact it is passed by ref instead of handle means the ref count was not incremented?
Is it better to take the rhs by handle to avoid the copy of the object?
class ObjectPicker : public ScriptRef
{
public:
std::vector<ObjectPick> mObjects;
ObjectPicker & ScriptAssign(const ObjectPicker & rhs)
{
mObjects = rhs.mObjects;
AddRef(); // because of returning object
return *this;
}
};
(ObjectPicker is registered as asOBJ_REF)
r = scriptEngine->RegisterObjectMethod("ObjectPicker", "ObjectPicker @ opAssign(const ObjectPicker &in)", asMETHOD(ObjectPicker,ScriptAssign), asCALL_THISCALL); assert( r >= 0 );