From: Benjamin Kramer Date: Fri, 13 Jan 2023 15:19:06 +0000 (+0100) Subject: [HashBuilder] Simplify with C++17. NFCI X-Git-Tag: upstream/17.0.6~21023 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c98768f3fff0933b1034944348e4e2f10fff444a;p=platform%2Fupstream%2Fllvm.git [HashBuilder] Simplify with C++17. NFCI --- 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