Hi all,
I'm in doubt and would like to hear opinions on the following issue.
boost::get for boost::variant was not making any compile time checks,
resulting in runtime errors where a compile time error must be:
boost::variant v(100);
boost::get<bool>(&v); // returns NULL instead of compile time error
boost::get<bool>(v); // throws exception on runtime instead of compile
time error
Now we have an implementation of compile time checked get in a separate
branch at git:
boost::variant v(100);
boost::safe_get<bool>(&v); // compile time error
boost::safe_get<bool>(v); // compile time error
boost::unsafe_get<bool>(&v); // returns NULL instead of compile time error
boost::unsafe_get<bool>(v); // throws exception on runtime instead of
compile time error
I'm in doubt, what the default behavior of boost::get must be:
* safe_get behavior is much closer to Standard Library behavior (just like
std::get for tuples) and allows to avoid errors in user code
* unsafe_get behavior is same as behavior of old boost::get and won't break
user's code if boost::get is used in some generic contexs
What's your opinion?
--
Best regards,
Antony Polukhin