fix(util/list): bug in map template

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-01 08:51:24 -08:00
parent 568931ccb1
commit 737e634556
2 changed files with 9 additions and 1 deletions

View file

@ -202,6 +202,13 @@ static void tst15() {
list<int>({1, 2, 2, 2, 3, 4}));
}
static void tst16() {
list<int> l({1, 2, 3, 4});
lean_assert_eq(map(l, [](int i) { return i + 10; }),
list<int>({11, 12, 13, 14}));
lean_assert_eq(map(list<int>(), [](int i) { return i + 10; }), list<int>());
}
int main() {
tst1();
tst2();
@ -218,5 +225,6 @@ int main() {
tst13();
tst14();
tst15();
tst16();
return has_violations() ? 1 : 0;
}

View file

@ -152,7 +152,7 @@ list<T> map(list<T> const & l, F && f) {
--i;
r = cons(f(tmp[i]->head()), r);
}
return l;
return r;
}
}