@@ -69,10 +69,13 @@ class unique_ref
6969 * Must not be null, otherwise it causes undefined behaviour.
7070 */
7171 explicit unique_ref (std::unique_ptr<object_type> ptr) :
72- p(std::move(ptr)){ASSERT (this ->p )}
72+ p(std::move(ptr))
73+ {
74+ utki::assert (this ->p , SL );
75+ }
7376
74- // there should be no default constructor, as unique_ref cannot be nullptr
75- unique_ref () = delete ;
77+ // there should be no default constructor, as unique_ref cannot be nullptr
78+ unique_ref () = delete ;
7679
7780 unique_ref (const unique_ref&) = delete ;
7881 unique_ref& operator =(const unique_ref&) = delete ;
@@ -96,7 +99,7 @@ class unique_ref
9699 unique_ref (unique_ref<other_object_type>&& sr) noexcept :
97100 p (std::move(sr.p))
98101 {
99- ASSERT (this ->p )
102+ utki::assert (this ->p , SL );
100103 }
101104
102105 /* *
@@ -106,7 +109,7 @@ class unique_ref
106109 */
107110 constexpr object_type& get () const noexcept
108111 {
109- ASSERT (this ->p )
112+ utki::assert (this ->p , SL );
110113 return *this ->p ;
111114 }
112115
@@ -118,6 +121,49 @@ class unique_ref
118121 {
119122 return this ->get ();
120123 }
124+
125+ /* *
126+ * @brief Less-than operator for comparison with another object.
127+ * Needed for using unique_ref in ordered containers (e.g. std::set).
128+ * Effecively calls opearator<() of the pointed-to object.
129+ * @return true if this object is less than the other object.
130+ * @return false otherwise.
131+ */
132+ friend constexpr bool operator <(const unique_ref& r, const object_type& o) noexcept
133+ {
134+ return r.get () < o;
135+ }
136+
137+ /* *
138+ * @brief Equality operator for comparison with another object.
139+ * Needed for using unique_ref in ordered containers (e.g. std::set).
140+ * Effectively calls operator==() of the pointed-to object.
141+ * @param r - left hand side of the operator.
142+ * @param o - right hand side of the operator.
143+ * @return true if this object is equal to the other object.
144+ * @return false otherwise.
145+ */
146+ friend constexpr bool operator ==(const unique_ref& r, const object_type& o) noexcept
147+ {
148+ return r.get () == o;
149+ }
150+
151+ /* *
152+ * @brief Equality operator for comparison with another object.
153+ * Needed for using unique_ref in ordered containers (e.g. std::set).
154+ * Effectively calls operator==() of the pointed-to object.
155+ * @param l - left hand side of the operator.
156+ * @param r - right hand side of the operator.
157+ * @return true if this object is equal to the other object.
158+ * @return false otherwise.
159+ */
160+ friend constexpr bool operator ==(
161+ const unique_ref& l, //
162+ const unique_ref& r
163+ ) noexcept
164+ {
165+ return l.get () == r.get ();
166+ }
121167};
122168
123169/* *
0 commit comments