diff --git a/executable_semantics/common/ptr.h b/executable_semantics/common/ptr.h index f9290fefb68a..ccb053c8e970 100644 --- a/executable_semantics/common/ptr.h +++ b/executable_semantics/common/ptr.h @@ -32,6 +32,9 @@ class Ptr { T* Get() const { return ptr; } + friend auto operator==(Ptr lhs, Ptr rhs) { return lhs.ptr == rhs.ptr; } + friend auto operator!=(Ptr lhs, Ptr rhs) { return lhs.ptr != rhs.ptr; } + private: T* ptr; }; diff --git a/executable_semantics/interpreter/interpreter.cpp b/executable_semantics/interpreter/interpreter.cpp index 0678894c761b..d19c7cacd393 100644 --- a/executable_semantics/interpreter/interpreter.cpp +++ b/executable_semantics/interpreter/interpreter.cpp @@ -1139,8 +1139,7 @@ struct DoTransition { void operator()(const UnwindTo& unwind_to) { Ptr frame = state->stack.Top(); - // TODO: drop .Get() calls once `Ptr` has comparison operators - while (frame->todo.Top().Get() != unwind_to.new_top.Get()) { + while (frame->todo.Top() != unwind_to.new_top) { if (IsBlockAct(frame->todo.Top())) { DeallocateScope(frame->scopes.Top()); frame->scopes.Pop();