Skip to content

Commit

Permalink
Code review round 3
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyRyabinin committed Feb 29, 2024
1 parent 59a4874 commit d422928
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions include/aws/crt/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,16 @@ namespace Aws

Variant(const Variant &other)
{
AWS_FATAL_ASSERT(other.m_index != -1);
m_index = other.m_index;
if (other.m_index != -1)
{
VisitorUtil<0, Ts...>::VisitBinary(this, other, CopyMoveConstructor());
}
VisitorUtil<0, Ts...>::VisitBinary(this, other, CopyMoveConstructor());
}

Variant(Variant &&other)
{
AWS_FATAL_ASSERT(other.m_index != -1);
m_index = other.m_index;
if (other.m_index != -1)
{
VisitorUtil<0, Ts...>::VisitBinary(this, std::move(other), CopyMoveConstructor());
}
VisitorUtil<0, Ts...>::VisitBinary(this, std::move(other), CopyMoveConstructor());
}

template <typename T, EnableIfOtherIsThisVariantAlternative<T> = 1> Variant(const T &val)
Expand Down Expand Up @@ -204,9 +200,9 @@ namespace Aws

Variant &operator=(const Variant &other)
{
AWS_ASSERT(other.m_index != -1);
if (this != &other && other.m_index != -1)
if (this != &other)
{
AWS_FATAL_ASSERT(other.m_index != -1);
if (m_index != other.m_index)
{
Destroy();
Expand All @@ -223,9 +219,9 @@ namespace Aws

Variant &operator=(Variant &&other)
{
AWS_ASSERT(other.m_index != -1);
if (this != &other && other.m_index != -1)
if (this != &other)
{
AWS_FATAL_ASSERT(other.m_index != -1);
if (m_index != other.m_index)
{
Destroy();
Expand Down Expand Up @@ -450,7 +446,7 @@ namespace Aws
typename std::remove_const<typename std::remove_reference<AlternativeT>::type>::type;
static_assert(std::is_same<PlaintT, PlaintOtherT>::value, "Incompatible types");

value = std::move(other);
value = other;
}
};

Expand Down

0 comments on commit d422928

Please sign in to comment.