Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the fixme (inline templated struct).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 9 Aug 2022 20:39:20 +0000 (22:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 9 Aug 2022 21:03:00 +0000 (23:03 +0200)
src/mc/VisitedState.cpp
src/mc/explo/Exploration.hpp
src/mc/explo/LivenessChecker.cpp

index 74c7147..8264c2a 100644 (file)
@@ -47,8 +47,9 @@ std::unique_ptr<simgrid::mc::VisitedState> VisitedStates::addVisitedState(unsign
   XBT_DEBUG("Snapshot %p of visited state %ld (exploration stack state %ld)", new_state->system_state.get(),
             new_state->num, graph_state->get_num());
 
-  auto [range_begin, range_end] =
-      boost::range::equal_range(states_, new_state.get(), compare_pair_by_actor_count_and_used_heap());
+  auto [range_begin, range_end] = boost::range::equal_range(states_, new_state.get(), [](auto const& a, auto const& b) {
+    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
+  });
 
   for (auto i = range_begin; i != range_end; ++i) {
     auto& visited_state = *i;
index ee5471c..9dfebd2 100644 (file)
@@ -66,18 +66,6 @@ XBT_PUBLIC Exploration* create_dfs_exploration(const std::vector<char*>& args, b
 XBT_PUBLIC Exploration* create_communication_determinism_checker(const std::vector<char*>& args, bool with_dpor);
 XBT_PUBLIC Exploration* create_udpor_checker(const std::vector<char*>& args);
 
-// FIXME: kill this template and use lambdas in boost::range_equal
-struct DerefAndCompareByActorsCountAndUsedHeap {
-  template <class X, class Y> bool operator()(X const& a, Y const& b) const
-  {
-    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
-  }
-};
-static inline DerefAndCompareByActorsCountAndUsedHeap compare_pair_by_actor_count_and_used_heap()
-{
-  return DerefAndCompareByActorsCountAndUsedHeap();
-}
-
 } // namespace simgrid::mc
 
 #endif
index ab212dc..26fb2a8 100644 (file)
@@ -62,8 +62,10 @@ std::shared_ptr<VisitedPair> LivenessChecker::insert_acceptance_pair(simgrid::mc
   auto new_pair =
       std::make_shared<VisitedPair>(pair->num, pair->prop_state_, pair->atomic_propositions, pair->app_state_);
 
-  auto [res_begin, res_end] =
-      boost::range::equal_range(acceptance_pairs_, new_pair.get(), compare_pair_by_actor_count_and_used_heap());
+  auto [res_begin,
+        res_end] = boost::range::equal_range(acceptance_pairs_, new_pair.get(), [](auto const& a, auto const& b) {
+    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
+  });
 
   if (pair->search_cycle)
     for (auto i = res_begin; i != res_end; ++i) {
@@ -139,8 +141,10 @@ int LivenessChecker::insert_visited_pair(std::shared_ptr<VisitedPair> visited_pa
     visited_pair =
         std::make_shared<VisitedPair>(pair->num, pair->prop_state_, pair->atomic_propositions, pair->app_state_);
 
-  auto [range_begin, range_end] =
-      boost::range::equal_range(visited_pairs_, visited_pair.get(), compare_pair_by_actor_count_and_used_heap());
+  auto [range_begin,
+        range_end] = boost::range::equal_range(visited_pairs_, visited_pair.get(), [](auto const& a, auto const& b) {
+    return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
+  });
 
   for (auto i = range_begin; i != range_end; ++i) {
     const VisitedPair* pair_test = i->get();