diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/generic/is_in.h | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/is_in.h')
-rw-r--r-- | util/generic/is_in.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/util/generic/is_in.h b/util/generic/is_in.h index 83f8f5645e..4f175ea5eb 100644 --- a/util/generic/is_in.h +++ b/util/generic/is_in.h @@ -1,53 +1,53 @@ #pragma once - + #include "typetraits.h" -#include <algorithm> +#include <algorithm> #include <initializer_list> template <class I, class T> -static inline bool IsIn(I f, I l, const T& v); +static inline bool IsIn(I f, I l, const T& v); template <class C, class T> -static inline bool IsIn(const C& c, const T& e); +static inline 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 <class T> + template <class T> using TIsAssocCont = TConjunction<THasFindMethod<T>, THasConstIterator<T>, THasKeyType<T>>; - template <class C, class T, bool isAssoc> - struct TIsInTraits { - static bool IsIn(const C& c, const T& e) { + template <class C, class T, bool isAssoc> + struct TIsInTraits { + static bool IsIn(const C& c, const T& e) { using std::begin; using std::end; return ::IsIn(begin(c), end(c), e); - } - }; - - template <class C, class T> - struct TIsInTraits<C, T, true> { - static bool IsIn(const C& c, const T& e) { - return c.find(e) != c.end(); - } - }; -} + } + }; + + template <class C, class T> + struct TIsInTraits<C, T, true> { + static bool IsIn(const C& c, const T& e) { + return c.find(e) != c.end(); + } + }; +} template <class I, class T> -static inline bool IsIn(I f, I l, const T& v) { - return std::find(f, l, v) != l; +static inline bool IsIn(I f, I l, const T& v) { + return std::find(f, l, v) != l; } template <class C, class T> -static inline bool IsIn(const C& c, const T& e) { +static inline bool IsIn(const C& c, const T& e) { using namespace NIsInHelper; return TIsInTraits<C, T, TIsAssocCont<C>::value>::IsIn(c, e); } template <class T, class U> static inline bool IsIn(std::initializer_list<T> l, const U& e) { - return ::IsIn(l.begin(), l.end(), e); + return ::IsIn(l.begin(), l.end(), e); } |