diff --git a/include/grpcpp/alarm.h b/include/grpcpp/alarm.h index 25882adc4d7..ab3e451cf67 100644 --- a/include/grpcpp/alarm.h +++ b/include/grpcpp/alarm.h @@ -72,8 +72,7 @@ class Alarm : private grpc::internal::GrpcLibrary { /// Alarms are movable. Alarm(Alarm&& rhs) noexcept : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; } Alarm& operator=(Alarm&& rhs) noexcept { - alarm_ = rhs.alarm_; - rhs.alarm_ = nullptr; + std::swap(alarm_, rhs.alarm_); return *this; }