Skip to content

Commit c62bd8f

Browse files
committed
feat: polystore find by pointer
1 parent ffbd06f commit c62bd8f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

include/boost/capy/polystore.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,25 @@ class polystore
200200
return static_cast<T*>(find(BOOST_CORE_TYPEID(T)));
201201
}
202202

203+
/** Assign the pointer for the object associated with `T`, or `nullptr`.
204+
205+
If no object of type `T` is stored, @p t is set to `nullptr`.
206+
207+
@par Thread Safety
208+
`const` member functions are thread-safe. Non-`const` functions
209+
must not run concurrently with any other member function on the
210+
same instance.
211+
212+
@param t The pointer to assign.
213+
@return `true` if an object of type `T` is present, otherwise `false`.
214+
*/
215+
template<class T>
216+
bool find(T*& t) const noexcept
217+
{
218+
t = find<T>();
219+
return t != nullptr;
220+
}
221+
203222
/** Return a reference to the object associated with type T
204223
205224
If no such object exists in the container, an exception is thrown.

0 commit comments

Comments
 (0)