From 0cfa7e4b5625749d2fc50d26afd24b7fd5b1136e Mon Sep 17 00:00:00 2001 From: Giuseppe Ottaviano Date: Mon, 27 Apr 2015 13:45:25 -0700 Subject: [PATCH] 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 --- folly/gen/Base.h | 12 ++++++------ folly/gen/test/BaseTest.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/folly/gen/Base.h b/folly/gen/Base.h index 1eec2fc9..093ee007 100644 --- a/folly/gen/Base.h +++ b/folly/gen/Base.h @@ -625,24 +625,24 @@ Until until(Predicate pred = Predicate()) { return Until(std::move(pred)); } -template> -Order orderBy(Selector selector = Identity(), +Order orderBy(Selector selector = Selector(), Comparer comparer = Comparer()) { return Order(std::move(selector), std::move(comparer)); } -template> -Order orderByDescending(Selector selector = Identity()) { +Order orderByDescending(Selector selector = Selector()) { return Order(std::move(selector)); } -template> -Distinct distinctBy(Selector selector = Identity()) { +Distinct distinctBy(Selector selector = Selector()) { return Distinct(std::move(selector)); } diff --git a/folly/gen/test/BaseTest.cpp b/folly/gen/test/BaseTest.cpp index 8fca7b93..26fba7b1 100644 --- a/folly/gen/test/BaseTest.cpp +++ b/folly/gen/test/BaseTest.cpp @@ -610,6 +610,14 @@ TEST(Gen, OrderBy) { | orderBy([](int x) { return (5.1 - x) * (5.1 - x); }) | as(); EXPECT_EQ(expected, actual); + + expected = seq(1, 10) | as(); + actual = + from(expected) + | map([] (int x) { return 11 - x; }) + | orderBy() + | as(); + EXPECT_EQ(expected, actual); } TEST(Gen, Foldl) { -- 2.34.1