jbeder / yaml-cpp

A YAML parser and emitter in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parameter takes default value if there is type conversion error

vrngupta53 opened this issue · comments

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.