From 1a93fbcd4519e62b1ced4309ac6c55b86da88c28 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 27 Jun 2018 15:21:59 -0700 Subject: [PATCH] Stop using the deprecated std::random_shuffle, for the benefit of MSVC. And generalize `hrandom_shuffle` to take an arbitrary `Iter`, so that passing `vec.begin()` will work even with MSVC's debug iterators. (Passing `&vec[0]` or `vec.data()` would work either way, but I'd worry that someone would forget to do that conscientiously every time.) --- game.cpp | 2 +- hyper.h | 1 - rogueviz-kohonen.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/game.cpp b/game.cpp index 6adf18ff..da7c13ad 100644 --- a/game.cpp +++ b/game.cpp @@ -4732,7 +4732,7 @@ void movehex(bool mounted, int colorpair) { for(int t=0; ttype; t++) if(c->mov[t] && inpair(c->mov[t], colorpair)) dirtable[qdirtable++] = t; - random_shuffle(dirtable, dirtable+qdirtable); + hrandom_shuffle(dirtable, qdirtable); while(qdirtable--) { int t = dirtable[qdirtable]; hexvisit(c->mov[t], c, t, mounted, colorpair); diff --git a/hyper.h b/hyper.h index 78f35ccc..71063b99 100644 --- a/hyper.h +++ b/hyper.h @@ -37,7 +37,6 @@ using std::imag; using std::stable_sort; using std::out_of_range; using std::get; -using std::random_shuffle; using std::move; using std::make_tuple; diff --git a/rogueviz-kohonen.cpp b/rogueviz-kohonen.cpp index 0a2eefb1..dd90f369 100644 --- a/rogueviz-kohonen.cpp +++ b/rogueviz-kohonen.cpp @@ -691,7 +691,7 @@ void describe(cell *c) { help += "\n"; vector> v; for(int s=0; snet, data[s].val), s); - random_shuffle(v.begin(), v.end()); + hrandom_shuffle(&v[0], isize(v)); sort(v.begin(), v.end(), [] (pair a, pair b) { return a.first < b.first; }); for(int i=0; i