Skip to content

Commit

Permalink
[impro] change std::for_each to ranged for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
raxyte committed Aug 3, 2023
1 parent b633491 commit 303693c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/dpp/event_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ template<class T> class event_router_t {
warning(event);
}
std::shared_lock l(lock);
std::for_each(dispatch_container.begin(), dispatch_container.end(), [&](auto &ev) {
for (const auto& ev : dispatch_container) {
if (!event.is_cancelled()) {
ev.second(event);
}
});
};
#ifdef DPP_CORO
auto coro_exception_handler = [from = event.from](std::exception_ptr ptr) {
try {
Expand All @@ -173,13 +173,13 @@ template<class T> class event_router_t {
from->creator->log(dpp::loglevel::ll_error, std::string{"Uncaught exception in event coroutine: "} + exception.what());
}
};
std::for_each(coroutine_container.begin(), coroutine_container.end(), [&](auto &ev) {
for (auto& ev : coroutine_container) {
if (!event.is_cancelled()) {
dpp::task<void> task = ev.second(event);

task.on_exception(coro_exception_handler);
}
});
};
#endif /* DPP_CORO */
};

Expand Down

0 comments on commit 303693c

Please sign in to comment.