|
Boost Users : |
Subject: Re: [Boost-users] bad_any_cast being thrown but no idea why
From: Michael Caisse (boost_at_[hidden])
Date: 2009-11-01 03:51:21
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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net