diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-31 22:52:52 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-02 11:28:08 +0200 |
| commit | 15b882d0416bb83a18e5437480c08419b2035e1f (patch) | |
| tree | 39da51bdd18a3203c519d36b458400f6c58c0c47 /libs/kstd/include | |
| parent | 77473afe9d5acb9450443b07b56d3dbc2f0639a6 (diff) | |
| download | teachos-15b882d0416bb83a18e5437480c08419b2035e1f.tar.xz teachos-15b882d0416bb83a18e5437480c08419b2035e1f.zip | |
kstd: add some basic observer_ptr tests
Diffstat (limited to 'libs/kstd/include')
| -rw-r--r-- | libs/kstd/include/kstd/observer_ptr | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/kstd/include/kstd/observer_ptr b/libs/kstd/include/kstd/observer_ptr index d3d24b4..97c9e5e 100644 --- a/libs/kstd/include/kstd/observer_ptr +++ b/libs/kstd/include/kstd/observer_ptr @@ -6,6 +6,7 @@ #include <compare> #include <concepts> #include <cstddef> +#include <type_traits> #include <utility> namespace kstd @@ -52,7 +53,7 @@ namespace kstd //! Reset the observer pointer. //! //! @param pointer The new object to watch. - constexpr auto reset(element_type * pointer) noexcept -> void + constexpr auto reset(element_type * pointer = nullptr) noexcept -> void { m_ptr = pointer; } @@ -84,7 +85,7 @@ namespace kstd //! Get the currently watched object. //! //! @return A reference to the currently watched object. - [[nodiscard]] constexpr auto operator*() const noexcept -> element_type & + [[nodiscard]] constexpr auto operator*() const noexcept -> std::add_lvalue_reference_t<element_type> { throw_on_null(); return *m_ptr; @@ -126,7 +127,7 @@ namespace kstd } //! The raw pointer to the watched object. - ElementType * m_ptr; + ElementType * m_ptr{}; }; //! Swap two observer pointers. |
