boost::any::unsafe_any_cast

  • Thread starter Norman J. Goldstein
  • Start date
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.
 
C

Cholo Lennon

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.

You will get a better answer in "gmane.comp.lib.boost.devel" newsgroup
(nntp server = news.gmane.org). Add "[any]" to your subject for a quick
response.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top