[PATCH] D24880: Add StringExtras join_items function

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 21:10:30 PDT 2016


mehdi_amini added inline comments.

================
Comment at: include/llvm/ADT/StringExtras.h:222
@@ +221,3 @@
+inline std::string join_items(Sep Separator, Args &&... Items) {
+  std::string Result;
+  detail::join_items_impl(Result, Separator, std::forward<Args>(Items)...);
----------------
zturner wrote:
> mehdi_amini wrote:
> > Could you add a "reserve" stage here?
> > 
> Seems reasonable, but how big?  `(max(1, sizeof...(Items)) - 1) * Separator.size())` is a lower bound.  Should I just go with that?
I'd have a variadic template (with some overload) that sum the length of each elements. So that the exact length is computed. This is what `join_impl` is doing iteratively I believe.



https://reviews.llvm.org/D24880





More information about the llvm-commits mailing list