diff --git a/src/vt/context/runnable_context/collection.cc b/src/vt/context/runnable_context/collection.cc index 41ebb250ff..666ef0cb7e 100644 --- a/src/vt/context/runnable_context/collection.cc +++ b/src/vt/context/runnable_context/collection.cc @@ -46,7 +46,7 @@ namespace vt { namespace ctx { void Collection::start() { - set_(); + set_(elm_); } void Collection::finish() { diff --git a/src/vt/context/runnable_context/collection.h b/src/vt/context/runnable_context/collection.h index a31246d95d..8b1abd67ae 100644 --- a/src/vt/context/runnable_context/collection.h +++ b/src/vt/context/runnable_context/collection.h @@ -87,8 +87,9 @@ struct Collection { void resume(); private: - std::function set_; /**< Set context function */ - std::function clear_; /**< Clear context function */ + std::function set_; /**< Set context function */ + std::function clear_; /**< Clear context function */ + void* elm_ = nullptr; /**< The element (untyped) */ }; }} /* end namespace vt::ctx */ diff --git a/src/vt/context/runnable_context/collection.impl.h b/src/vt/context/runnable_context/collection.impl.h index 9a22c23bc4..403cc960f8 100644 --- a/src/vt/context/runnable_context/collection.impl.h +++ b/src/vt/context/runnable_context/collection.impl.h @@ -54,9 +54,11 @@ template /*explicit*/ Collection::Collection( vrt::collection::Indexable* elm ) { - auto idx_ = elm->getIndex(); - auto proxy_ = elm->getProxy(); - set_ = [=]{ + elm_ = elm; + set_ = [](void* in_elm){ + auto e = static_cast*>(in_elm); + auto& idx_ = e->getIndex(); + auto proxy_ = e->getProxy(); vrt::collection::CollectionContextHolder::set(&idx_, proxy_); }; clear_ = []{