1 #pragma once 2 3 #include <algorithm> 4 5 namespace utils 6 { 7 namespace detail 8 { 9 10 template <class T> 11 concept HasMemberFind = 12 requires(T container) { container.find(container.begin()->first); }; 13 14 template <class T> 15 concept HasMemberContains = 16 requires(T container) { container.contains(*container.begin()); }; 17 18 } // namespace detail 19 20 template <detail::HasMemberFind T> contains(const T & container,const typename T::value_type::first_type & key)21inline bool contains(const T& container, 22 const typename T::value_type::first_type& key) 23 { 24 return container.find(key) != container.end(); 25 } 26 27 template <detail::HasMemberContains T> contains(const T & container,const typename T::value_type & key)28inline bool contains(const T& container, const typename T::value_type& key) 29 { 30 return container.contains(key); 31 } 32 33 template <class T> contains(const T & container,const typename T::value_type & key)34inline bool contains(const T& container, const typename T::value_type& key) 35 { 36 return std::find(container.begin(), container.end(), key) != 37 container.end(); 38 } 39 40 } // namespace utils 41