diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index a43c107501..2ebbfe3045 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -157,9 +157,12 @@ struct ObjGroupManager : runtime::component::Component { * \brief Collectively construct a new object group from a raw pointer to the * object. * - * \warning This overload requires the caller to manage the lifetime of the - * object. Do not allow the object to be deallocated before the object group - * is destroyed. + * \note When \c obj is \c nullptr this overload constructs the objgroup with + * the default constructor. + * + * \warning This overload (when not \c nullptr ) requires the caller to manage + * the lifetime of the object. Do not allow the object to be deallocated + * before the object group is destroyed. * * \param[in] obj raw pointer to the object * \param[in] label object group label @@ -167,7 +170,7 @@ struct ObjGroupManager : runtime::component::Component { * \return proxy to the object group */ template - ProxyType makeCollective(ObjT* obj, std::string const& label = {}); + ProxyType makeCollective(ObjT* obj = nullptr, std::string const& label = {}); /** * \brief Collectively construct a new object group from a smart-pointer-like diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index dffb5f7917..ec4ce824e8 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -79,7 +79,9 @@ ObjGroupManager::makeCollective(std::string const& label, Args&&... args) { template ObjGroupManager::ProxyType ObjGroupManager::makeCollective(ObjT* obj, std::string const& label) { - vtAssert(obj != nullptr, "Must be a valid obj pointer"); + if (obj == nullptr) { + return makeCollective("unlabeled"); + } auto holder_base = std::make_unique>(obj); return makeCollectiveObj(label, obj, std::move(holder_base)); }