Skip to content

Commit

Permalink
one more folly::join overload
Browse files Browse the repository at this point in the history
Summary: To allow codemod changes.

Test Plan: ran test

Reviewed By: tudorb@fb.com

FB internal diff: D549516
  • Loading branch information
philippv authored and tudor committed Aug 26, 2012
1 parent 43c9729 commit 2bfec0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions folly/String.h
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions folly/test/StringTest.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 2bfec0d

Please sign in to comment.