55// /*****************************************************************************
66
77#include < cmath>
8+ #include < execution>
89#include < iterator>
910
1011#include " state_management.hpp"
@@ -43,9 +44,10 @@ void Caretaker::garbage_collector() noexcept {
4344 });
4445
4546 // Step 3: for each originator, erase blacklisted nodes.
46- for ( auto & ptr : originators)
47+ for_each (execution::unseq, begin (originators), end (originators), [&]( auto const & ptr) {
4748 if (auto originator = ptr.lock (); originator)
4849 originator->erase (to_remove);
50+ });
4951
5052 // Step 4: erase annotations related to blacklisted nodes.
5153 erase_if (annotations, [&](auto const & item) {
@@ -181,9 +183,10 @@ void Caretaker::remember_current_timepoint() noexcept {
181183bool Caretaker::go_without_remembering (Timepoint* t) noexcept {
182184 if (t && t->root () == history_root.get ()) {
183185 current_timepoint = t;
184- for (auto & it : originators)
185- if (auto ptr = it.lock (); ptr)
186- ptr->go (t);
186+ for_each (execution::unseq, begin (originators), end (originators), [&](auto const & ptr) {
187+ if (auto originator = ptr.lock (); originator)
188+ originator->go (t);
189+ });
187190 return true ;
188191 } else {
189192 return false ;
@@ -199,7 +202,7 @@ bool Caretaker::go_and_remember(Timepoint* t) noexcept {
199202}
200203
201204// ******************************************************************************
202- void Caretaker::annotate_current_timepoint (std:: unique_ptr<IAnnotation> annotation) noexcept {
205+ void Caretaker::annotate_current_timepoint (unique_ptr<IAnnotation> annotation) noexcept {
203206 annotations.emplace (current_timepoint, std::move (annotation));
204207}
205208
@@ -214,7 +217,7 @@ IAnnotation* Caretaker::get_annotation(Timepoint* t) noexcept {
214217// In predicate, you will probably want to downcast to a well-known user-defined
215218// type.
216219// ******************************************************************************
217- Timepoint* Caretaker::find_first_ancestor_with_annotation_that (std:: function<bool (IAnnotation const *)> const & predicate, bool include_itself) noexcept {
220+ Timepoint* Caretaker::find_first_ancestor_with_annotation_that (function<bool (IAnnotation const *)> const & predicate, bool include_itself) noexcept {
218221 for (auto * t : current_timepoint->ancestors (include_itself))
219222 if (annotations.contains (t) && predicate (annotations.at (t).get ()))
220223 return t;
0 commit comments