summaryrefslogtreecommitdiff
path: root/lib/nes/common/box.hh
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-02-04 23:11:08 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-02-04 23:11:08 +0100
commit79553ab1fa3d707612e80dd03bf95ca65fa0c411 (patch)
treef44bec41548d569cfca43c44e0e4ffa7b72ed4ed /lib/nes/common/box.hh
parent9c45e9c7df1efa5bc1c8e73b6eaef4726b828d3e (diff)
refactor file browser
Diffstat (limited to 'lib/nes/common/box.hh')
-rw-r--r--lib/nes/common/box.hh29
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/nes/common/box.hh b/lib/nes/common/box.hh
index 3a65613..7bf2848 100644
--- a/lib/nes/common/box.hh
+++ b/lib/nes/common/box.hh
@@ -1,6 +1,7 @@
#pragma once
#include "nes/common/types.hh"
+#include "nes/common/debug.hh"
namespace nes
{
@@ -28,10 +29,30 @@ namespace nes
auto operator=(box const&) -> box& = delete;
auto operator=(box&&) -> box& = delete;
- auto operator*() -> T& { return *get(); }
- auto operator*() const -> T const& { return *get(); }
- auto operator->() -> T* { return get(); }
- auto operator->() const -> T const* { return get(); }
+ auto operator*() -> T&
+ {
+ NES_ASSERT(has_value() && "expected box to be non-empty");
+ return *get();
+ }
+
+ auto operator*() const -> T const&
+ {
+ NES_ASSERT(has_value() && "expected box to be non-empty");
+ return *get();
+ }
+
+ auto operator->() -> T*
+ {
+ NES_ASSERT(has_value() && "expected box to be non-empty");
+ return get();
+ }
+
+ auto operator->() const -> T const*
+ {
+ NES_ASSERT(has_value() && "expected box to be non-empty");
+ return get();
+ }
+
operator bool() const { return has_value(); }
auto has_value() const -> bool { return initialized_; }