File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: functions that are useful with optionalt
4
+
5
+ Author: Diffblue Ltd.
6
+
7
+ \*******************************************************************/
8
+
9
+ #ifndef CPROVER_UTIL_OPTIONAL_UTILS_H
10
+ #define CPROVER_UTIL_OPTIONAL_UTILS_H
11
+
12
+ #include " optional.h"
13
+
14
+ #include < iterator>
15
+ #include < map>
16
+
17
+ // / Lookup a key in a map, if found return the associated value, nullopt otherwise
18
+ template <typename map_like_collectiont, typename keyt>
19
+ auto optional_lookup (const map_like_collectiont &map, const keyt &key)
20
+ -> optionalt<decltype(map.find(key)->second)>
21
+ {
22
+ auto const it = map.find (key);
23
+ if (it != map.end ())
24
+ {
25
+ return it->second ;
26
+ }
27
+ return nullopt;
28
+ }
29
+
30
+ #endif // CPROVER_UTIL_OPTIONAL_UTILS_H
You can’t perform that action at this time.
0 commit comments