diff --git a/common/checked_save_and_restore.h b/common/checked_save_and_restore.h index 10ecfca1ed9e..aee93437a9af 100644 --- a/common/checked_save_and_restore.h +++ b/common/checked_save_and_restore.h @@ -12,11 +12,12 @@ namespace Carbon { // Sets a variable to a new value, and restores the original value when -// the SetAndRestore is destroyed. CHECKs that the variable is still holding the -// new value when restoring the original value, to catch any data loss. +// the CheckedSaveAndRestore is destroyed. CHECKs that the variable is still +// holding the new value when restoring the original value, to catch any data +// loss. // // The value must be copyable in order to compare with the new value at the time -// the SetAndRestore is destroyed. +// the CheckedSaveAndRestore is destroyed. template class [[nodiscard]] CheckedSaveAndRestore { public: @@ -30,6 +31,10 @@ class [[nodiscard]] CheckedSaveAndRestore { *var_ = std::move(orig_value_); } + CheckedSaveAndRestore(const CheckedSaveAndRestore&) = delete; + auto operator=(const CheckedSaveAndRestore&) + -> CheckedSaveAndRestore& = delete; + private: T* var_; T new_value_;