Add default "default" value of "false" to boolean options, therefore allowing to call result["boolOpt"].as<bool>() without throwing an exception.
This commit is contained in:
parent
24162899c9
commit
9a13d34825
@ -855,13 +855,13 @@ namespace cxxopts
|
|||||||
|
|
||||||
standard_value()
|
standard_value()
|
||||||
{
|
{
|
||||||
set_implicit();
|
set_default_and_implicit();
|
||||||
}
|
}
|
||||||
|
|
||||||
standard_value(bool* b)
|
standard_value(bool* b)
|
||||||
: abstract_value(b)
|
: abstract_value(b)
|
||||||
{
|
{
|
||||||
set_implicit();
|
set_default_and_implicit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Value>
|
std::shared_ptr<Value>
|
||||||
@ -873,8 +873,10 @@ namespace cxxopts
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void
|
void
|
||||||
set_implicit()
|
set_default_and_implicit()
|
||||||
{
|
{
|
||||||
|
m_default = true;
|
||||||
|
m_default_value = "false";
|
||||||
m_implicit = true;
|
m_implicit = true;
|
||||||
m_implicit_value = "true";
|
m_implicit_value = "true";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user