Commit 133d8937 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

eachToTuple: use to<fbstring>(delim) instead of delim

Summary: eachToTuple: use to<fbstring>(delim) instead of delim

Reviewed By: yfeldblum

Differential Revision: D16419866

fbshipit-source-id: 7a57f41ea210c569284f6c619784adc95f03b26e
parent dd15371c
......@@ -150,7 +150,8 @@ detail::Map<detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>>
eachToTuple(StringPiece delim) {
return detail::Map<
detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>>(
detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>(delim));
detail::SplitTo<std::tuple<Targets...>, fbstring, Targets...>(
to<fbstring>(delim)));
}
template <class First, class Second>
......
......@@ -190,6 +190,21 @@ TEST(StringGen, EachToTuple) {
};
EXPECT_EQ(expected, actual);
}
{
// StringPiece target
auto lines = "1::cat 2::dog";
// clang-format off
auto actual
= split(lines, ' ')
| eachToTuple<int, StringPiece>("::")
| as<vector>();
// clang-format on
vector<tuple<int, StringPiece>> expected{
make_tuple(1, "cat"),
make_tuple(2, "dog"),
};
EXPECT_EQ(expected, actual);
}
{
// Empty field
auto lines = "2:tjackson:4 3::5";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment