// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include #include template struct IsWeightedType : std::false_type {}; template struct IsWeightedType> : std::true_type {}; struct value_then_weight_order { template bool operator()(const T& lhs, const T& rhs) const noexcept { if (lhs.getValue() != rhs.getValue()) { return (lhs.getValue() < rhs.getValue()); } return (lhs.getWeight() < rhs.getWeight()); } }; struct order_by_value { template bool operator()(const T& lhs, const T& rhs) const noexcept { if constexpr (IsWeightedType::value) { return (lhs.getValue() < rhs.getValue()); } else { return (lhs < rhs); } } }; struct order_by_weight { template bool operator()(const search::attribute::WeightedType& lhs, const search::attribute::WeightedType& rhs) const noexcept { return (lhs.getWeight() < rhs.getWeight()); } };