cannot decode signed char
this snippet throws:
auto node = YAML::Load("-126");
try {
const auto y = node.as<signed char>();
std::cout << "y = " << static_cast<int>(y) << '\n';
}
catch (const YAML::TypedBadConversion<signed char>& error) {
std::cerr << error.what() << '\n';
}
but -126 fits inside a signed char
It should be noted that
std::is_same<char, signed char>::value == false;
std::is_same<char, unsigned char>::value == false;
std::is_same<signed char, unsigned char>::value == false;
there are three types of distinct "char" types. The first one, char, should be seen as a "character", so should be serialized as a "character", whereas signed char and unsigned char should be seen as "numbers" and so should be serialized as "numbers". See: C++14 standard (working draft), section 3.9.1.
Somewhat of a "me too", but I've just run into this myself and am somewhat confused. I'm not trying to parse negative numbers, but something like 40 or 29.
Asking for .as<std::uint8_t>() or .as<unsigned char>() gets me the same exception reported by @rwols.
Only .as<unsigned int>() works for some reason.
I'm curious about this one as well.