From 89cf0c1e8c7bf08f21fdd57960c744dcb1493a36 Mon Sep 17 00:00:00 2001 From: gin0606 Date: Tue, 12 Aug 2014 11:56:08 +0900 Subject: [PATCH] fix getEngine --- cocos/base/ccRandom.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/base/ccRandom.h b/cocos/base/ccRandom.h index 2be07b6a95..9bb813d29d 100644 --- a/cocos/base/ccRandom.h +++ b/cocos/base/ccRandom.h @@ -37,18 +37,18 @@ public: template static inline T random_real(T min, T max) { std::uniform_real_distribution dist(min, max); - std::mt19937 mt = RandomHelper::getEngine(); + auto &mt = RandomHelper::getEngine(); return dist(mt); } template static inline T random_int(T min, T max) { std::uniform_int_distribution<> dist(min, max); - std::mt19937 mt = RandomHelper::getEngine(); + auto &mt = RandomHelper::getEngine(); return dist(mt); } private: - static std::mt19937 getEngine() { + static std::mt19937 &getEngine() { static std::random_device seed_gen; static std::mt19937 engine(seed_gen()); return engine;