[Glacier] Call an object's destructor in an ErrorOr

This commit is contained in:
Drew Galbraith 2023-11-02 22:16:06 -07:00
parent f31652b981
commit f8f839d8e7
1 changed files with 5 additions and 2 deletions

View File

@ -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) {}