151497a0cSKrzysztof Grobelny #pragma once 251497a0cSKrzysztof Grobelny 351497a0cSKrzysztof Grobelny #include <algorithm> 451497a0cSKrzysztof Grobelny 551497a0cSKrzysztof Grobelny namespace utils 651497a0cSKrzysztof Grobelny { 751497a0cSKrzysztof Grobelny namespace detail 851497a0cSKrzysztof Grobelny { 951497a0cSKrzysztof Grobelny 1051497a0cSKrzysztof Grobelny template <class T> 11*7e114c04SSzymon Dompke concept HasMemberFind = 12*7e114c04SSzymon Dompke requires(T container) { container.find(container.begin()->first); }; 1351497a0cSKrzysztof Grobelny 14fdb06a14SSzymon Dompke template <class T> 15*7e114c04SSzymon Dompke concept HasMemberContains = 16*7e114c04SSzymon Dompke requires(T container) { container.contains(*container.begin()); }; 17fdb06a14SSzymon Dompke 1851497a0cSKrzysztof Grobelny } // namespace detail 1951497a0cSKrzysztof Grobelny 2051497a0cSKrzysztof Grobelny template <detail::HasMemberFind T> contains(const T & container,const typename T::value_type::first_type & key)2151497a0cSKrzysztof Grobelnyinline bool contains(const T& container, 2251497a0cSKrzysztof Grobelny const typename T::value_type::first_type& key) 2351497a0cSKrzysztof Grobelny { 2451497a0cSKrzysztof Grobelny return container.find(key) != container.end(); 2551497a0cSKrzysztof Grobelny } 2651497a0cSKrzysztof Grobelny 27fdb06a14SSzymon Dompke template <detail::HasMemberContains T> contains(const T & container,const typename T::value_type & key)28fdb06a14SSzymon Dompkeinline bool contains(const T& container, const typename T::value_type& key) 29fdb06a14SSzymon Dompke { 30fdb06a14SSzymon Dompke return container.contains(key); 31fdb06a14SSzymon Dompke } 32fdb06a14SSzymon Dompke 3351497a0cSKrzysztof Grobelny template <class T> contains(const T & container,const typename T::value_type & key)3451497a0cSKrzysztof Grobelnyinline bool contains(const T& container, const typename T::value_type& key) 3551497a0cSKrzysztof Grobelny { 3651497a0cSKrzysztof Grobelny return std::find(container.begin(), container.end(), key) != 3751497a0cSKrzysztof Grobelny container.end(); 3851497a0cSKrzysztof Grobelny } 3951497a0cSKrzysztof Grobelny 4051497a0cSKrzysztof Grobelny } // namespace utils 41