strings join
[folly.git] / folly / String.h
index 604c0883ff4a31359b753747a54ecd2521a02056..906a9f376df7cfccdeb56850d87dd990854a561b 100644 (file)
@@ -333,6 +333,26 @@ void splitTo(const Delim& delimiter,
              OutputIterator out,
              bool ignoreEmpty = false);
 
+/*
+ * Join list of tokens.
+ *
+ * Stores a string representation of tokens in the same order with
+ * deliminer between each element.
+ */
+
+template <class Delim, class Iterator, class String>
+void join(const Delim& delimiter,
+          Iterator begin,
+          Iterator end,
+          String& output);
+
+template <class Delim, class Container, class String>
+void join(const Delim& delimiter,
+          const Container& container,
+          String& output) {
+  join(delimiter, container.begin(), container.end(), output);
+}
+
 } // namespace folly
 
 // Hash functions for string and fbstring usable with e.g. hash_map