replace typeid() with is_unsigned()

This commit is contained in:
dota17 2020-05-18 16:35:50 +08:00
parent 776743bb6c
commit d31f4f4096
2 changed files with 3 additions and 7 deletions

View File

@ -4,7 +4,7 @@
## HEAD ##
_none_
* Throws an exception when trying to parse a negative number as an unsigned integer.
## 0.6.0 ##

View File

@ -15,7 +15,7 @@
#include <sstream>
#include <type_traits>
#include <vector>
#include <typeinfo>
#include <type_traits>
#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<type>::value) { \
return false; \
} \
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) { \