« Return to Thread: bad_any_cast being thrown but no idea why

Re: bad_any_cast being thrown but no idea why

by Michael Caisse-2 :: Rate this Message:

Reply to Author | View in Thread

John Yamokoski wrote:

>> Hi John -
>>
>> The problem is that the RTTI id's are different between your lib
>> and the executable. You can use the undocumented and very useful
>> unsafe cast:
>>
>>        boost::unsafe_any_cast< std::string>( ... )
>>
>> Of course, this creates a problem since it is not safe and if the
>> any doesn't contain a std::string there will be a surprise.
>>
>>    
>
> Michael,
>
> Well its great to hear there's some sort of explanation for this.
> Unfortunately, from my compiler, I get:
>
> no matching function for call to 'unsafe_any_cast(const boost::any&)'
>
> I believe I have installed Boost version 1.40. I will gladly downgrade
> to an earlier version if unsafe_any_cast was finally eliminated in
> 1.40. Otherwise is there another way to deal with RTTI ID issues? This
> is the first I have heard of them. Ahhh.. so close though.
>  

John -

It is still in the interface:

https://svn.boost.org/trac/boost/browser/tags/release/Boost_1_40_0/boost/any.hpp#L219

Did you remember the template parameter?

        boost::unsafe_any_cast< std::string>( ... )

Do you have a small code snippet that reproduces the problem?

michael


--

----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com


_______________________________________________
Boost-users mailing list
Boost-users@...
http://lists.boost.org/mailman/listinfo.cgi/boost-users

 « Return to Thread: bad_any_cast being thrown but no idea why