CBMC
optional_utils.h
Go to the documentation of this file.
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
16
template
<
typename
map_like_collectiont,
typename
keyt>
17
auto
optional_lookup
(
const
map_like_collectiont &map,
const
keyt &key)
18
->
optionalt
<decltype(map.find(key)->second)>
19
{
20
auto
const
it = map.find(key);
21
if
(it != map.end())
22
{
23
return
it->second;
24
}
25
return
{};
26
}
27
28
#endif // CPROVER_UTIL_OPTIONAL_UTILS_H
optional.h
optional_lookup
auto optional_lookup(const map_like_collectiont &map, const keyt &key) -> optionalt< decltype(map.find(key) ->second)>
Lookup a key in a map, if found return the associated value, nullopt otherwise.
Definition:
optional_utils.h:17
optionalt
nonstd::optional< T > optionalt
Definition:
optional.h:35
src
util
optional_utils.h
Generated by
1.8.17