From 8a1cc7f8f947949ec0a6022235cea978acc743ac Mon Sep 17 00:00:00 2001 From: Lingxuan Zuo Date: Thu, 2 Jul 2020 18:32:41 +0800 Subject: [PATCH] Reset bool config by checking type first (#9247) --- src/ray/common/ray_config.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ray/common/ray_config.h b/src/ray/common/ray_config.h index 0a38f0597..2c93dbb95 100644 --- a/src/ray/common/ray_config.h +++ b/src/ray/common/ray_config.h @@ -14,7 +14,9 @@ #pragma once +#include #include +#include #include #include "ray/util/logging.h" @@ -50,8 +52,17 @@ class RayConfig { /// A helper macro that helps to set a value to a config item. #define RAY_CONFIG(type, name, default_value) \ if (pair.first == #name) { \ - std::istringstream stream(pair.second); \ - stream >> name##_; \ + if (typeid(type) == typeid(bool)) { \ + std::string value = pair.second; \ + std::transform(value.begin(), \ + value.end(), \ + value.begin(), \ + ::tolower); \ + name##_ = value == "true"; \ + } else { \ + std::istringstream stream(pair.second); \ + stream >> name##_; \ + } \ continue; \ }