[llvm] 111c298 - [ADT] Simplify determining size for joining items
Joe Loser via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 20 10:54:52 PST 2022
Author: Joe Loser
Date: 2022-11-20T11:51:22-07:00
New Revision: 111c29802161daa493a926b621341d88f29d19c4
URL: https://github.com/llvm/llvm-project/commit/111c29802161daa493a926b621341d88f29d19c4
DIFF: https://github.com/llvm/llvm-project/commit/111c29802161daa493a926b621341d88f29d19c4.diff
LOG: [ADT] Simplify determining size for joining items
`join_items_size` uses recursive function templates for determining the total
items size. Instead, use fold expressions since we have C++17 available now.
Differential Revision: https://reviews.llvm.org/D138375
Added:
Modified:
llvm/include/llvm/ADT/StringExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/StringExtras.h b/llvm/include/llvm/ADT/StringExtras.h
index ee6c33924e963..eec010e893228 100644
--- a/llvm/include/llvm/ADT/StringExtras.h
+++ b/llvm/include/llvm/ADT/StringExtras.h
@@ -451,14 +451,8 @@ template <typename T> inline size_t join_one_item_size(const T &Str) {
return Str.size();
}
-inline size_t join_items_size() { return 0; }
-
-template <typename A1> inline size_t join_items_size(const A1 &A) {
- return join_one_item_size(A);
-}
-template <typename A1, typename... Args>
-inline size_t join_items_size(const A1 &A, Args &&... Items) {
- return join_one_item_size(A) + join_items_size(std::forward<Args>(Items)...);
+template <typename... Args> inline size_t join_items_size(Args &&...Items) {
+ return (0 + ... + join_one_item_size(std::forward<Args>(Items)));
}
} // end namespace detail
More information about the llvm-commits
mailing list