utils: add contains function

This commit is contained in:
Maxime Coste 2011-10-17 21:05:22 +00:00
parent 316e84f119
commit 1c6eef08f1

View File

@ -5,6 +5,7 @@
#include "assert.hh" #include "assert.hh"
#include <memory> #include <memory>
#include <algorithm>
namespace Kakoune namespace Kakoune
{ {
@ -99,6 +100,13 @@ private:
template<typename T> template<typename T>
T* Singleton<T>::ms_instance = nullptr; T* Singleton<T>::ms_instance = nullptr;
template<typename Container, typename T>
bool contains(const Container& container, const T& value)
{
return std::find(container.begin(), container.end(), value)
!= container.end();
}
} }
#endif // utils_hh_INCLUDED #endif // utils_hh_INCLUDED