Boost logo

Boost Users :

Subject: [Boost-users] [type_erasure] [docs]contrast with boost::any
From: Larry Evans (cppljevans_at_[hidden])
Date: 2012-07-23 16:37:13


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 page:

http://steven_watanabe.users.sourceforge.net/type_erasure/libs/type_erasure/doc/html/boost_typeerasure/basic.html

says:

x is approximately equivalent to a boost::any

however, it doesn't say how te::any differs from boost::any.

The attached shows that a boost::any can change it's
type, and, as such, is somewhat like boost::variant.
However, te::any, once it's created, cannot change
it's type, AFAICT. At least that's what the
attached code indicates when compiled with:

 #define SHOW_TE_FIXED_TYPE

With that #define, the error produced by gcc4.8 is:

../../../boost/type_erasure/any.hpp:702:9: note: mismatched types
'const boost::type_erasure::assignable<boost::type_erasure::_a, U>' and
'void'
         _boost_type_erasure_assign_impl(
         ^

In contrast, without that #define, the boost::any has no problem
changing it's type and produces output:

typeinfo(bnd_value_ptr_v)=double*
typeinfo(bnd_displacement_v)=int
a_any=stk_displacement_v; any_cast<displacement_t>=0x97eb58
a_any=stk_value_ptr_v; any_cast<displacement_t>=0;
any_cast<value_ptr_t>=0x97eb78

The code uses a compiler specific demangler, also attached.

-regards,
Larry





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