#include using namespace std; void apply_events(Context & c, vector const v) { for (auto & event : v) event->apply(c); } int main() { Context c { }; Named_Context nc { "My Context" }; // add different events to the vector // at least one of each type vector v {}; apply_events(c, v); apply_events(nc, v); }