mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Add move semantics to Ref.
This commit is contained in:
parent
bf1c2583f4
commit
28d6cf859a
1 changed files with 14 additions and 0 deletions
|
|
@ -127,6 +127,15 @@ public:
|
||||||
ref(p_from);
|
ref(p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator=(Ref &&p_from) {
|
||||||
|
if (reference == p_from.reference) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unref();
|
||||||
|
reference = p_from.reference;
|
||||||
|
p_from.reference = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T_Other>
|
template <typename T_Other>
|
||||||
void operator=(const Ref<T_Other> &p_from) {
|
void operator=(const Ref<T_Other> &p_from) {
|
||||||
ref_pointer<false>(Object::cast_to<T>(p_from.ptr()));
|
ref_pointer<false>(Object::cast_to<T>(p_from.ptr()));
|
||||||
|
|
@ -159,6 +168,11 @@ public:
|
||||||
this->operator=(p_from);
|
this->operator=(p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref(Ref &&p_from) {
|
||||||
|
reference = p_from.reference;
|
||||||
|
p_from.reference = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T_Other>
|
template <typename T_Other>
|
||||||
Ref(const Ref<T_Other> &p_from) {
|
Ref(const Ref<T_Other> &p_from) {
|
||||||
this->operator=(p_from);
|
this->operator=(p_from);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue