
On 07/25/12 10:57, Larry Evans wrote:
On 07/18/12 00:13, Lorenzo Caminiti wrote:
Hello all,
*** The review of Steven Watanabe's proposed Boost.TypeErasure library begins on July 18, 2012 and ends on July 27, 2012. ***
The attached produces runtime error:
./rebind_any.exe creating b_self any(const U&) creating b_copy terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::type_erasure::bad_any_cast>
' what(): std::bad_cast make: *** [run] Aborted
Yet, the type returned by rebind_any was used in the any_cast; hence, it must be a good cast, AFAICT.
What am I doing wrong?
OOPS. I should have realized that the AnyB arg to rebind_any has no information about what's the actual type stored in the b_self because AnyB was defined before b_self was created. Sorry for noise. However, the doc: http://steven_watanabe.users.sourceforge.net/type_erasure/libs/type_erasure/... was a bit confusing since it says: A metafunction that returns any type corresponding to a placeholder. If T is not a placeholder, returns T unchanged. Since the T was _self, which is a placeholder, I assumed it would return the type corresponding to _self; however, since that's unknown until the actual Any is created, it must return something else. I actually demangled the type returned and it was: b_type=boost::type_erasure::any<boost::mpl::vector<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, boost::type_erasure::typeid_<boost::type_erasure::_self>, boost::type_erasure::addable<boost::type_erasure::_self, boost::type_erasure::_self, boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self> which looks like it's just the Any template arg to rebind_any, which leaves me wondering what's the purpose of rebind_any. -regards, Larry