Add move semantics (constructor, assignment) to StringName.

This commit is contained in:
Lukas Tenbrink 2024-12-16 18:58:22 +01:00
parent b9437c3938
commit 8c4e674770

View file

@ -188,8 +188,22 @@ public:
}; };
StringName &operator=(const StringName &p_name); StringName &operator=(const StringName &p_name);
StringName &operator=(StringName &&p_name) {
if (_data == p_name._data) {
return *this;
}
unref();
_data = p_name._data;
p_name._data = nullptr;
return *this;
}
StringName(const char *p_name, bool p_static = false); StringName(const char *p_name, bool p_static = false);
StringName(const StringName &p_name); StringName(const StringName &p_name);
StringName(StringName &&p_name) {
_data = p_name._data;
p_name._data = nullptr;
}
StringName(const String &p_name, bool p_static = false); StringName(const String &p_name, bool p_static = false);
StringName(const StaticCString &p_static_string, bool p_static = false); StringName(const StaticCString &p_static_string, bool p_static = false);
StringName() {} StringName() {}