From c98768f3fff0933b1034944348e4e2f10fff444a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 13 Jan 2023 16:19:06 +0100 Subject: [PATCH] [HashBuilder] Simplify with C++17. NFCI --- llvm/include/llvm/Support/HashBuilder.h | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/Support/HashBuilder.h b/llvm/include/llvm/Support/HashBuilder.h index c13e7d2..04a7b2e 100644 --- a/llvm/include/llvm/Support/HashBuilder.h +++ b/llvm/include/llvm/Support/HashBuilder.h @@ -261,13 +261,12 @@ public: template HashBuilderImpl &add(const std::pair &Value) { - add(Value.first); - add(Value.second); - return *this; + return add(Value.first, Value.second); } template HashBuilderImpl &add(const std::tuple &Arg) { - return addTupleHelper(Arg, typename std::index_sequence_for()); + std::apply([this](const auto &...Args) { this->add(Args...); }, Arg); + return *this; } /// A convenenience variadic helper. @@ -280,12 +279,10 @@ public: /// add(Arg1) /// add(Arg2) /// ``` - template - std::enable_if_t<(sizeof...(Ts) >= 1), HashBuilderImpl &> - add(const T &FirstArg, const Ts &...Args) { - add(FirstArg); - add(Args...); - return *this; + template + std::enable_if_t<(sizeof...(Ts) > 1), HashBuilderImpl &> + add(const Ts &...Args) { + return (add(Args), ...); } template @@ -325,13 +322,6 @@ public: } private: - template - HashBuilderImpl &addTupleHelper(const std::tuple &Arg, - std::index_sequence) { - add(std::get(Arg)...); - return *this; - } - // FIXME: Once available, specialize this function for `contiguous_iterator`s, // and use it for `ArrayRef` and `StringRef`. template -- 2.7.4