cprover
map_visit.h
Go to the documentation of this file.
1/*******************************************************************\
2
3 Module: apply a function to values in a shared_map
4
5 Author: Jez Higgins
6
7\*******************************************************************/
8#ifndef CPROVER_ANALYSES_VARIABLE_SENSITIVITY_MAP_VISIT_H
9#define CPROVER_ANALYSES_VARIABLE_SENSITIVITY_MAP_VISIT_H
10
11template <class mapt, class visitort>
12bool visit_map(mapt &map, const visitort &visitor)
13{
14 bool modified = false;
15 for(auto &item : map.get_view())
16 {
17 auto newval = visitor.visit(item.second);
18 if(newval != item.second)
19 {
20 map.replace(item.first, std::move(newval));
21 modified = true;
22 }
23 }
24 return modified;
25}
26
27#endif // CPROVER_ANALYSES_VARIABLE_SENSITIVITY_MAP_VISIT_H
bool visit_map(mapt &map, const visitort &visitor)
Definition: map_visit.h:12