From d31f4f4096e8affd4a5972707552801a24c16f0c Mon Sep 17 00:00:00 2001 From: dota17 Date: Mon, 18 May 2020 16:35:50 +0800 Subject: [PATCH] replace typeid() with is_unsigned() --- docs/Breaking-Changes.md | 2 +- include/yaml-cpp/node/convert.h | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/Breaking-Changes.md b/docs/Breaking-Changes.md index 85103cd..3b23127 100644 --- a/docs/Breaking-Changes.md +++ b/docs/Breaking-Changes.md @@ -4,7 +4,7 @@ ## HEAD ## -_none_ + * Throws an exception when trying to parse a negative number as an unsigned integer. ## 0.6.0 ## diff --git a/include/yaml-cpp/node/convert.h b/include/yaml-cpp/node/convert.h index 7164022..db7e44d 100644 --- a/include/yaml-cpp/node/convert.h +++ b/include/yaml-cpp/node/convert.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "yaml-cpp/binary.h" #include "yaml-cpp/node/impl.h" @@ -134,11 +134,7 @@ inner_encode(const T& rhs, std::stringstream& stream){ const std::string& input = node.Scalar(); \ std::stringstream stream(input); \ stream.unsetf(std::ios::dec); \ - if ((stream.peek() == '-') && \ - (typeid(rhs) == typeid(unsigned) || \ - typeid(rhs) == typeid(unsigned short) || \ - typeid(rhs) == typeid(unsigned long) || \ - typeid(rhs) == typeid(unsigned long long))) { \ + if ((stream.peek() == '-') && std::is_unsigned::value) { \ return false; \ } \ if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) { \