From f8f839d8e7607864b471799cfb80d3d8bda7fc00 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Thu, 2 Nov 2023 22:16:06 -0700 Subject: [PATCH] [Glacier] Call an object's destructor in an ErrorOr --- lib/glacier/status/error_or.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/glacier/status/error_or.h b/lib/glacier/status/error_or.h index 728ab02..74f82fb 100644 --- a/lib/glacier/status/error_or.h +++ b/lib/glacier/status/error_or.h @@ -11,8 +11,11 @@ class ErrorOr { ErrorOr() = delete; ErrorOr(const ErrorOr&) = delete; ErrorOr(ErrorOr&&) = delete; - // FIXME: Do we have to call ~T manually here. - ~ErrorOr() {} + ~ErrorOr() { + if (ok_) { + obj_.~T(); + } + } ErrorOr(ErrorCode code) : error_(code), ok_(false) {} ErrorOr(const T& obj) : obj_(obj), ok_(true) {}