1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

pass lambdas to functions by reference, not by value zenorogue/hyperrogue#25

This commit is contained in:
Zeno Rogue 2018-06-12 22:17:08 +02:00
parent c23d893df2
commit 520e5e5dbb
3 changed files with 5 additions and 4 deletions

View File

@ -3892,7 +3892,7 @@ int pickDownDirection(cell *c, flagtype mf) {
}
template<class T>
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;

View File

@ -48,7 +48,7 @@ bool test_uniq(cellwalker cw, int z, int lev, cell *par) {
return true;
}
template<class T> void recursively(cell *c, cell *c1, T t) {
template<class T> void recursively(cell *c, cell *c1, const T& t) {
t(c);
for(int i=0; i<c->type; i++)
if(c->mov[i] && c->spin(i) == 0 && c->mov[i] != c1)

View File

@ -1619,7 +1619,7 @@ string cname() {
return "coord-67.txt";
}
template<class T> function<void(presmode)> roguevizslide(char c, T t) {
template<class T> function<void(presmode)> roguevizslide(char c, const T& t) {
return [c,t] (presmode mode) {
patterns::canvasback = 0x101010;
setCanvas(mode, c);
@ -1638,7 +1638,8 @@ template<class T> function<void(presmode)> roguevizslide(char c, T t) {
};
}
template<class T, class T1> function<void(presmode)> roguevizslide_action(char c, T t, T1 act) {
template<class T, class U>
function<void(presmode)> roguevizslide_action(char c, const T& t, const U& act) {
return [c,t,act] (presmode mode) {
patterns::canvasback = 0x101010;
setCanvas(mode, c);