Permalink
Browse files

one more folly::join overload

Summary: To allow codemod changes.

Test Plan: ran test

Reviewed By: tudorb@fb.com

FB internal diff: D549516
  • Loading branch information...
1 parent 43c9729 commit 2bfec0de99d40ef333c21d9388952fcd2abd09b0 @philippv philippv committed with tudor Aug 15, 2012
Showing with 12 additions and 0 deletions.
  1. +8 −0 folly/String.h
  2. +4 −0 folly/test/StringTest.cpp
View
@@ -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
@@ -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);

0 comments on commit 2bfec0d

Please sign in to comment.