Commit | Line | Data |
---|---|---|
237a48ad PP |
1 | /* |
2 | * Copyright (c) 2024 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: MIT | |
5 | */ | |
6 | ||
7 | #ifndef BABELTRACE_CPP_COMMON_BT2C_CONTAINS_HPP | |
8 | #define BABELTRACE_CPP_COMMON_BT2C_CONTAINS_HPP | |
9 | ||
10 | namespace bt2c { | |
11 | ||
12 | /* | |
13 | * Returns whether or not the STL container `container` contains the | |
14 | * value `val`. | |
15 | */ | |
16 | template <typename T, typename V> | |
17 | bool contains(const T& container, const V& val) noexcept | |
18 | { | |
19 | return container.find(val) != container.end(); | |
20 | } | |
21 | ||
22 | } /* namespace bt2c */ | |
23 | ||
24 | #endif /* BABELTRACE_CPP_COMMON_BT2C_CONTAINS_HPP */ |