aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/is_in.h
diff options
context:
space:
mode:
authorswarmer <swarmer@yandex-team.ru>2022-06-01 06:11:45 +0300
committerswarmer <swarmer@yandex-team.ru>2022-06-01 06:11:45 +0300
commit915804dc0bd9143e3cdbbe71927598c5023cbecc (patch)
tree84cb9512ba5470c124a1dd61b950d10e048a771a /util/generic/is_in.h
parent3b85dd2989f96c6173ff583494f4f7d11c388fd4 (diff)
downloadydb-915804dc0bd9143e3cdbbe71927598c5023cbecc.tar.gz
[util] constexpr для алгоритмов
ref:f1a82a410e24de6f4a77f4c8f28ed3401a5516b4
Diffstat (limited to 'util/generic/is_in.h')
-rw-r--r--util/generic/is_in.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/util/generic/is_in.h b/util/generic/is_in.h
index 4f175ea5eb..643edba596 100644
--- a/util/generic/is_in.h
+++ b/util/generic/is_in.h
@@ -6,10 +6,10 @@
#include <initializer_list>
template <class I, class T>
-static inline bool IsIn(I f, I l, const T& v);
+constexpr bool IsIn(I f, I l, const T& v);
template <class C, class T>
-static inline bool IsIn(const C& c, const T& e);
+constexpr bool IsIn(const C& c, const T& e);
namespace NIsInHelper {
Y_HAS_MEMBER(find, FindMethod);
@@ -21,7 +21,7 @@ namespace NIsInHelper {
template <class C, class T, bool isAssoc>
struct TIsInTraits {
- static bool IsIn(const C& c, const T& e) {
+ static constexpr bool IsIn(const C& c, const T& e) {
using std::begin;
using std::end;
return ::IsIn(begin(c), end(c), e);
@@ -30,24 +30,24 @@ namespace NIsInHelper {
template <class C, class T>
struct TIsInTraits<C, T, true> {
- static bool IsIn(const C& c, const T& e) {
+ static constexpr 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) {
+constexpr 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) {
+constexpr 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) {
+constexpr bool IsIn(std::initializer_list<T> l, const U& e) {
return ::IsIn(l.begin(), l.end(), e);
}