aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util/OptionalRef.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-22 15:10:49 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-22 15:10:49 +0100
commitd038f192c7dcb453c9fc19082cd1b642c8f70fc8 (patch)
treebcb539657cd8b35ed742f19e5673c777ab39610c /src/crepe/util/OptionalRef.h
parentc3c3476f1d82aa83d8f8dc706488475dc2cf1e55 (diff)
parent4117d1d287f1d87efd0577d56819520e981a7f1c (diff)
merge with `master`
Diffstat (limited to 'src/crepe/util/OptionalRef.h')
-rw-r--r--src/crepe/util/OptionalRef.h36
1 files changed, 10 insertions, 26 deletions
diff --git a/src/crepe/util/OptionalRef.h b/src/crepe/util/OptionalRef.h
index 8417a25..3201667 100644
--- a/src/crepe/util/OptionalRef.h
+++ b/src/crepe/util/OptionalRef.h
@@ -23,20 +23,7 @@ public:
*
* \return Reference to this (required for operator)
*/
- OptionalRef<T> & operator=(T & ref);
- /**
- * \brief Check if this reference is not empty
- *
- * \returns `true` if reference is set, or `false` if it is not
- */
- explicit operator bool() const noexcept;
-
- /**
- * \brief Assign new reference
- *
- * \param ref Reference to assign
- */
- void set(T &) noexcept;
+ OptionalRef<T> & operator=(T & ref);
/**
* \brief Retrieve this reference
*
@@ -44,21 +31,19 @@ public:
*
* \throws std::runtime_error if this function is called while the reference it not set
*/
- T & get() const;
+ operator T &() const;
+ /**
+ * \brief Check if this reference is not empty
+ *
+ * \returns `true` if reference is set, or `false` if it is not
+ */
+ explicit operator bool() const noexcept;
+
/**
* \brief Make this reference empty
*/
void clear() noexcept;
- //! Copy constructor
- OptionalRef(const OptionalRef<T> &);
- //! Move constructor
- OptionalRef(OptionalRef<T> &&);
- //! Copy assignment
- OptionalRef<T> & operator=(const OptionalRef<T> &);
- //! Move assignment
- OptionalRef<T> & operator=(OptionalRef<T> &&);
-
private:
/**
* \brief Reference to the value of type \c T
@@ -68,7 +53,6 @@ private:
T * ref = nullptr;
};
-}
+} // namespace crepe
#include "OptionalRef.hpp"
-