one more folly::join overload
authorPhilip Pronin <philipp@fb.com>
Wed, 15 Aug 2012 20:52:40 +0000 (13:52 -0700)
committerTudor Bosman <tudorb@fb.com>
Sun, 26 Aug 2012 18:13:38 +0000 (11:13 -0700)
Summary: To allow codemod changes.

Test Plan: ran test

Reviewed By: tudorb@fb.com

FB internal diff: D549516

folly/String.h
folly/test/StringTest.cpp

index 906a9f376df7cfccdeb56850d87dd990854a561b..bd7b0114478571fe98c7c252aeb0f255e8827f25 100644 (file)
@@ -353,6 +353,14 @@ void join(const Delim& delimiter,
   join(delimiter, container.begin(), container.end(), output);
 }
 
+template <class Delim, class Container>
+std::string join(const Delim& delimiter,
+                 const Container& container) {
+  std::string output;
+  join(delimiter, container.begin(), container.end(), output);
+  return output;
+}
+
 } // namespace folly
 
 // Hash functions for string and fbstring usable with e.g. hash_map
index df5c689121e7120dacd93e330442de0f4608b27f..ec01eb6c628c26dce6409208381ce19c99022a2d 100644 (file)
@@ -644,10 +644,14 @@ TEST(String, join) {
   std::vector<std::string> input1 = { "1", "23", "456", "" };
   join(':', input1, output);
   EXPECT_EQ(output, "1:23:456:");
+  output = join(':', input1);
+  EXPECT_EQ(output, "1:23:456:");
 
   auto input2 = { 1, 23, 456 };
   join("-*-", input2, output);
   EXPECT_EQ(output, "1-*-23-*-456");
+  output = join("-*-", input2);
+  EXPECT_EQ(output, "1-*-23-*-456");
 
   auto input3 = { 'f', 'a', 'c', 'e', 'b', 'o', 'o', 'k' };
   join("", input3, output);