add a find(container, value) utility function
This commit is contained in:
parent
e386c49868
commit
14d17a4493
|
@ -100,11 +100,16 @@ private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T* Singleton<T>::ms_instance = nullptr;
|
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>
|
template<typename Container, typename T>
|
||||||
bool contains(const Container& container, const T& value)
|
bool contains(const Container& container, const T& value)
|
||||||
{
|
{
|
||||||
return std::find(container.begin(), container.end(), value)
|
return find(container, value) != container.end();
|
||||||
!= container.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string str_to_str(const std::string& str)
|
inline std::string str_to_str(const std::string& str)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user