Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
raii_utils.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <cassert>
7
12class ScopedBool
13{
14public:
15 explicit ScopedBool (bool &flag) : flag_ (flag)
16 {
17 assert (!flag_);
18 flag_ = true;
19 }
20 ~ScopedBool ()
21 {
22 assert (flag_);
23 flag_ = false;
24 }
25
26 ScopedBool (const ScopedBool &) = delete;
27 ScopedBool &operator= (const ScopedBool &) = delete;
28 ScopedBool (ScopedBool &&) = delete;
29 ScopedBool &operator= (ScopedBool &&) = delete;
30
31private:
32 bool &flag_;
33};