When using the automatic conversion of a config attribute to a bool, such as with:
bool b = cfg["some_attribute"]
The variable b will always be false regardless of the attribute's actual value. This is due to calling operator int() in config_attribute_value.hpp instead of explicit operator bool(), which results in using the attribute_numeric_visitor which uses the default value of 0 for bool values instead of its actual value.
Potential solutions mentioned by celticminstrel from IRC:
Remove the explicit annotation on operator bool().
Remove operator bool() entirely, and also remove operator int().
Remove operator bool() and replace operator int() with a custom function using a different visitor that returns 0 or 1 if the value is a bool.
Any fix for this issue should also include test cases added to the boost unit tests for this behavior as well.
When using the automatic conversion of a config attribute to a bool, such as with:
The variable
b
will always be false regardless of the attribute's actual value. This is due to callingoperator int()
inconfig_attribute_value.hpp
instead ofexplicit operator bool()
, which results in using theattribute_numeric_visitor
which uses the default value of 0 for bool values instead of its actual value.Potential solutions mentioned by celticminstrel from IRC:
Any fix for this issue should also include test cases added to the boost unit tests for this behavior as well.