summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-01-25 22:31:47 +0000
committerMaxime Coste <frrrwww@gmail.com>2012-01-25 22:31:47 +0000
commit14d17a44935513cce35bc90aabe25fb21d152f65 (patch)
tree58dbe1666bac4ed974ceb35460d18e210f337082 /src
parente386c49868f0b38ffbd65e5f75fa79a826ad03b2 (diff)
add a find(container, value) utility function
Diffstat (limited to 'src')
-rw-r--r--src/utils.hh9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/utils.hh b/src/utils.hh
index 6a196053..9e9aa453 100644
--- a/src/utils.hh
+++ b/src/utils.hh
@@ -101,10 +101,15 @@ template<typename T>
T* Singleton<T>::ms_instance = nullptr;
template<typename Container, typename T>
+auto find(Container& container, const T& value) -> decltype(container.begin())
+{
+ return std::find(container.begin(), container.end(), value);
+}
+
+template<typename Container, typename T>
bool contains(const Container& container, const T& value)
{
- return std::find(container.begin(), container.end(), value)
- != container.end();
+ return find(container, value) != container.end();
}
inline std::string str_to_str(const std::string& str)