From 14d17a44935513cce35bc90aabe25fb21d152f65 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 25 Jan 2012 22:31:47 +0000 Subject: [PATCH] add a find(container, value) utility function --- src/utils.hh | 9 +++++++-- 1 file 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 @@ -100,11 +100,16 @@ private: template T* Singleton::ms_instance = nullptr; +template +auto find(Container& container, const T& value) -> decltype(container.begin()) +{ + return std::find(container.begin(), container.end(), value); +} + template 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)