diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp index 5983a7fc754..83d10b365bf 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp @@ -24,6 +24,14 @@ AttributedStringBox::AttributedStringBox( std::shared_ptr const &opaquePointer) : mode_(Mode::OpaquePointer), value_({}), opaquePointer_(opaquePointer) {} +AttributedStringBox::AttributedStringBox(AttributedStringBox &&other) noexcept + : mode_(other.mode_), + value_(std::move(other.value_)), + opaquePointer_(std::move(other.opaquePointer_)) { + other.mode_ = AttributedStringBox::Mode::Value; + other.value_ = std::make_shared(AttributedString{}); +} + AttributedStringBox::Mode AttributedStringBox::getMode() const { return mode_; } @@ -40,6 +48,18 @@ std::shared_ptr AttributedStringBox::getOpaquePointer() const { return opaquePointer_; } +AttributedStringBox &AttributedStringBox::operator=( + AttributedStringBox &&other) { + if (this != &other) { + mode_ = other.mode_; + value_ = std::move(other.value_); + opaquePointer_ = std::move(other.opaquePointer_); + other.mode_ = AttributedStringBox::Mode::Value; + other.value_ = std::make_shared(AttributedString{}); + } + return *this; +} + bool operator==( AttributedStringBox const &lhs, AttributedStringBox const &rhs) { @@ -48,9 +68,9 @@ bool operator==( } switch (lhs.getMode()) { - case facebook::react::AttributedStringBox::Mode::Value: + case AttributedStringBox::Mode::Value: return lhs.getValue() == rhs.getValue(); - case facebook::react::AttributedStringBox::Mode::OpaquePointer: + case AttributedStringBox::Mode::OpaquePointer: return lhs.getOpaquePointer() == rhs.getOpaquePointer(); } } diff --git a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h index 7965a7d6d28..b8bd96c9cae 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h +++ b/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h @@ -41,9 +41,9 @@ class AttributedStringBox final { * Movable, Copyable, Assignable. */ AttributedStringBox(AttributedStringBox const &other) = default; - AttributedStringBox(AttributedStringBox &&other) noexcept = default; + AttributedStringBox(AttributedStringBox &&other) noexcept; AttributedStringBox &operator=(AttributedStringBox const &other) = default; - AttributedStringBox &operator=(AttributedStringBox &&other) = default; + AttributedStringBox &operator=(AttributedStringBox &&other); /* * Getters.