#pragma once #include "typetraits.h" #include #include template constexpr bool IsIn(I f, I l, const T& v); template constexpr bool IsIn(const C& c, const T& e); namespace NIsInHelper { Y_HAS_MEMBER(find, FindMethod); Y_HAS_SUBTYPE(const_iterator, ConstIterator); Y_HAS_SUBTYPE(key_type, KeyType); template using TIsAssocCont = TConjunction, THasConstIterator, THasKeyType>; template struct TIsInTraits { static constexpr bool IsIn(const C& c, const T& e) { using std::begin; using std::end; return ::IsIn(begin(c), end(c), e); } }; template struct TIsInTraits { static constexpr bool IsIn(const C& c, const T& e) { return c.find(e) != c.end(); } }; } // namespace NIsInHelper template constexpr bool IsIn(I f, I l, const T& v) { return std::find(f, l, v) != l; } template constexpr bool IsIn(const C& c, const T& e) { using namespace NIsInHelper; return TIsInTraits::value>::IsIn(c, e); } template constexpr bool IsIn(std::initializer_list l, const U& e) { return ::IsIn(l.begin(), l.end(), e); }