[boost::variant] problems with pointers
After much inefficient debugging, I've discovered that adding a pointer type to a boost::variant is a no-no. It appears to get translated into a bool via get<>, which throws a bad_get exception erroneously (at least in my opinion). The caviots of using a pointer type in variant really needs to be documented! It doesn't appear to be done so now. I've discovered that wrapping the pointer in a boost::shared_pointer is a solution. But it wasn't obvious.
Jeffrey Holle wrote:
After much inefficient debugging, I've discovered that adding a pointer type to a boost::variant is a no-no. It appears to get translated into a bool via get<>, which throws a bad_get exception erroneously (at least in my opinion).
The caviots of using a pointer type in variant really needs to be documented! It doesn't appear to be done so now.
I've discovered that wrapping the pointer in a boost::shared_pointer is a solution. But it wasn't obvious.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Jeffrey,
f.ex:
variant
participants (2)
-
David Klein
-
Jeffrey Holle