jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
4.91k stars 1.78k forks source link

Parameter takes default value if there is type conversion error #1228

Open vrngupta53 opened 9 months ago

vrngupta53 commented 9 months ago

With a YAML config {"x": "1.0"} The statement int a = node["x"].as<int>() throws a YAML::TypedBadConversion exception. But if I add a default value, int a = node["x"].as<int>(0), then the variable a takes the default value of 0 quietly without throwing any errors. Why is this? I would want to see an error in this case as well.