The following lines will not throw an exception at run-time:
boost::optional<double> dummy(boost::none);
double testValue = *dummy;
Is there a reason why boost developers have decided to not throw when using the indirection operator (*
) on a boost::optional
containing boost::none
? For reference, I get random values in testValue
in the code above as it is probably assigning random unitialised parts of memory.
This can lead to silent errors as you are responsible of checking the value before to use it.
I can think of 2:
It is the same case as for array bounds checking: nice to have, but expensive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With