aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-20 13:17:27 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-05-20 13:18:51 +0000
commitec9ef7bba03fe9287fe37a8c88f9d025a4b2ef67 (patch)
tree8bc8417e895e509af4b9c333e3ea08525f475736 /searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h
parentf5f7b0cb60569fc05c100a8b83b9fd721ec37183 (diff)
Fold searchcommon into searchlib
Diffstat (limited to 'searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h')
-rw-r--r--searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h b/searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h
new file mode 100644
index 00000000000..f03b031f991
--- /dev/null
+++ b/searchlib/src/vespa/searchcommon/attribute/multi_value_traits.h
@@ -0,0 +1,35 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include <type_traits>
+
+namespace search::multivalue {
+
+template <typename T> class WeightedValue;
+
+/*
+ * Check for the presence of a weight.
+ */
+template <typename T>
+struct is_WeightedValue : std::false_type {};
+
+template <typename T>
+struct is_WeightedValue<WeightedValue<T>> : std::true_type {};
+
+template <typename T>
+inline constexpr bool is_WeightedValue_v = is_WeightedValue<T>::value;
+
+/*
+ * Extract inner type.
+ */
+template <typename T>
+struct ValueType { using type = T; };
+
+template <typename T>
+struct ValueType<WeightedValue<T>> { using type = T; };
+
+template <typename T>
+using ValueType_t = typename ValueType<T>::type;
+
+}