tint: Add Symbol inequality operator
Allows Symbol to be used in a std::variant Change-Id: If366622c39b5c25d633f6507467c9859394577c3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112283 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
c158e845e6
commit
75b18674bf
|
@ -42,6 +42,11 @@ bool Symbol::operator==(const Symbol& other) const {
|
|||
return val_ == other.val_;
|
||||
}
|
||||
|
||||
bool Symbol::operator!=(const Symbol& other) const {
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Symbol, program_id_, other.program_id_);
|
||||
return val_ != other.val_;
|
||||
}
|
||||
|
||||
bool Symbol::operator<(const Symbol& other) const {
|
||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Symbol, program_id_, other.program_id_);
|
||||
return val_ < other.val_;
|
||||
|
|
|
@ -63,11 +63,16 @@ class Symbol {
|
|||
/// @returns teh symbol after doing the move
|
||||
Symbol& operator=(Symbol&& o);
|
||||
|
||||
/// Comparison operator
|
||||
/// Equality operator
|
||||
/// @param o the other symbol
|
||||
/// @returns true if the symbols are the same
|
||||
bool operator==(const Symbol& o) const;
|
||||
|
||||
/// Inequality operator
|
||||
/// @param o the other symbol
|
||||
/// @returns true if the symbols are the different
|
||||
bool operator!=(const Symbol& o) const;
|
||||
|
||||
/// Less-than operator
|
||||
/// @param o the other symbol
|
||||
/// @returns true if this symbol is ordered before symbol `o`
|
||||
|
|
|
@ -43,8 +43,11 @@ TEST_F(SymbolTest, Comparison) {
|
|||
Symbol sym3(1, program_id);
|
||||
|
||||
EXPECT_TRUE(sym1 == sym3);
|
||||
EXPECT_FALSE(sym1 != sym3);
|
||||
EXPECT_FALSE(sym1 == sym2);
|
||||
EXPECT_TRUE(sym1 != sym2);
|
||||
EXPECT_FALSE(sym3 == sym2);
|
||||
EXPECT_TRUE(sym3 != sym2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue