Skip to content

Commit

Permalink
Bug 1232418 - Allow mozilla::Tuple to support equality comparison; r=…
Browse files Browse the repository at this point in the history
…Waldo

--HG--
extra : rebase_source : d57231f1c4a4c58715d2d552dd2e02257a73891e
  • Loading branch information
Terrence Cole committed Dec 14, 2015
1 parent 6ab8c8c commit 0ef3ab8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion mfbt/Tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ struct TupleImpl;
* of an empty tuple).
*/
template<std::size_t Index>
struct TupleImpl<Index> {};
struct TupleImpl<Index> {
bool operator==(const TupleImpl<Index>& aOther) const
{
return true;
}
};

/*
* One node of the recursive inheritance hierarchy. It stores the element at
Expand Down Expand Up @@ -182,6 +187,10 @@ struct TupleImpl<Index, HeadT, TailT...>
Tail(*this) = Move(Tail(aOther));
return *this;
}
bool operator==(const TupleImpl& aOther) const
{
return Head(*this) == Head(aOther) && Tail(*this) == Tail(aOther);
}
private:
HeadT mHead; // The element stored at this index in the tuple.
};
Expand Down Expand Up @@ -246,6 +255,10 @@ class Tuple : public detail::TupleImpl<0, Elements...>
static_cast<Impl&>(*this) = Move(aOther);
return *this;
}
bool operator==(const Tuple& aOther) const
{
return static_cast<const Impl&>(*this) == static_cast<const Impl&>(aOther);
}
};

/**
Expand Down

0 comments on commit 0ef3ab8

Please sign in to comment.