9class [[nodiscard]] ScopedValue {
11 explicit ScopedValue(T& value, T replacement)
noexcept(
12 std::is_nothrow_move_constructible_v<T> && std::is_nothrow_move_assignable_v<T>
15 mPrevious(std::exchange(value, std::move(replacement))) {}
17 ~ScopedValue()
noexcept(std::is_nothrow_move_assignable_v<T>) { mValue = std::move(mPrevious); }
19 ScopedValue(ScopedValue
const&) =
delete;
20 ScopedValue& operator=(ScopedValue
const&) =
delete;
21 ScopedValue(ScopedValue&&) =
delete;
22 ScopedValue& operator=(ScopedValue&&) =
delete;