N
Norman J. Goldstein
The following comment is at the bottom of boost/any.hpp
// Note: The "unsafe" versions of any_cast are not part of the
// public interface and may be removed at any time. They are
// required where we know what type is stored in the any and can't
// use typeid() comparison, e.g., when our types may travel across
// different shared libraries.
I would urge the keeping of unsafe_any_cast in the public interface.
There is another situation, which I would think is quite common, when
accessing the stored value:
When we know only a base class of the stored type, then unsafe_any_cast
is the way to get hold of the value. The stricter any_cast requires an
exact match of the typeid's.
// Note: The "unsafe" versions of any_cast are not part of the
// public interface and may be removed at any time. They are
// required where we know what type is stored in the any and can't
// use typeid() comparison, e.g., when our types may travel across
// different shared libraries.
I would urge the keeping of unsafe_any_cast in the public interface.
There is another situation, which I would think is quite common, when
accessing the stored value:
When we know only a base class of the stored type, then unsafe_any_cast
is the way to get hold of the value. The stricter any_cast requires an
exact match of the typeid's.