mirror of
https://github.com/clearlinux/folly.git
synced 2026-09-01 02:34:43 +00:00
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
This commit is contained in:
committed by
Andrii Grynenko
parent
f8147e89c8
commit
0cfa7e4b56
+6
-6
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user