Commit 0cfa7e4b authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Andrii Grynenko

Fix default arguments for orderBy()

Summary: Calling `folly::gen::orderBy()` without arguments causes a compilation error because the first template argument cannot be deduced. This diff fixes it.

Test Plan:
fbconfig -r folly && fbmake runtests

Reviewed By: philipp@fb.com

Subscribers: folly-diffs@, yfeldblum, chalfant

FB internal diff: D2025789

Signature: t1:2025789:1430167404:02fde7287b015d9dcbf398e8dc84cde7d74b4a5b
parent f8147e89
......@@ -625,24 +625,24 @@ Until until(Predicate pred = Predicate()) {
return Until(std::move(pred));
}
template<class Selector,
template<class Selector = Identity,
class Comparer = Less,
class Order = detail::Order<Selector, Comparer>>
Order orderBy(Selector selector = Identity(),
Order orderBy(Selector selector = Selector(),
Comparer comparer = Comparer()) {
return Order(std::move(selector),
std::move(comparer));
}
template<class Selector,
template<class Selector = Identity,
class Order = detail::Order<Selector, Greater>>
Order orderByDescending(Selector selector = Identity()) {
Order orderByDescending(Selector selector = Selector()) {
return Order(std::move(selector));
}
template<class Selector,
template<class Selector = Identity,
class Distinct = detail::Distinct<Selector>>
Distinct distinctBy(Selector selector = Identity()) {
Distinct distinctBy(Selector selector = Selector()) {
return Distinct(std::move(selector));
}
......
......@@ -610,6 +610,14 @@ TEST(Gen, OrderBy) {
| orderBy([](int x) { return (5.1 - x) * (5.1 - x); })
| as<vector>();
EXPECT_EQ(expected, actual);
expected = seq(1, 10) | as<vector>();
actual =
from(expected)
| map([] (int x) { return 11 - x; })
| orderBy()
| as<vector>();
EXPECT_EQ(expected, actual);
}
TEST(Gen, Foldl) {
......
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