From 520e5e5dbbe4e78f1b762a8ff7c0742083b72717 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 12 Jun 2018 22:17:08 +0200 Subject: [PATCH] pass lambdas to functions by reference, not by value zenorogue/hyperrogue#25 --- game.cpp | 2 +- rogueviz-banachtarski.cpp | 2 +- rogueviz.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/game.cpp b/game.cpp index 2f5ecdc2..eddb812f 100644 --- a/game.cpp +++ b/game.cpp @@ -3892,7 +3892,7 @@ int pickDownDirection(cell *c, flagtype mf) { } template -cell *determinePush(cellwalker who, cell *c2, int subdir, T valid) { +cell *determinePush(cellwalker who, cell *c2, int subdir, const T& valid) { if(subdir != 1 && subdir != -1) { subdir = 1; static bool first = true; diff --git a/rogueviz-banachtarski.cpp b/rogueviz-banachtarski.cpp index ecbc9a5c..43d098be 100644 --- a/rogueviz-banachtarski.cpp +++ b/rogueviz-banachtarski.cpp @@ -48,7 +48,7 @@ bool test_uniq(cellwalker cw, int z, int lev, cell *par) { return true; } -template void recursively(cell *c, cell *c1, T t) { +template void recursively(cell *c, cell *c1, const T& t) { t(c); for(int i=0; itype; i++) if(c->mov[i] && c->spin(i) == 0 && c->mov[i] != c1) diff --git a/rogueviz.cpp b/rogueviz.cpp index 5ecb97a7..a1ad2ced 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -1619,7 +1619,7 @@ string cname() { return "coord-67.txt"; } -template function roguevizslide(char c, T t) { +template function roguevizslide(char c, const T& t) { return [c,t] (presmode mode) { patterns::canvasback = 0x101010; setCanvas(mode, c); @@ -1638,7 +1638,8 @@ template function roguevizslide(char c, T t) { }; } -template function roguevizslide_action(char c, T t, T1 act) { +template +function roguevizslide_action(char c, const T& t, const U& act) { return [c,t,act] (presmode mode) { patterns::canvasback = 0x101010; setCanvas(mode, c);