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