Boost logo

Boost Users :

Subject: Re: [Boost-users] [any] Is it possible to support polymorphism in boost::any?
From: Germán Diago (germandiago_at_[hidden])
Date: 2010-09-07 04:14:03


This feature is a must!

2010/9/7 Tang Jiang Jun <tangjiangjun_at_[hidden]>:
> That's an excellent idea!
> It's so concise and delicate to use different internal holders to represent
> different sub-objects.
> However I have a question about the query. How should a any object find
> which holder is the correct one to the casting query for one special base
> class?
> Thanks!
>
>
> On Mon, Sep 6, 2010 at 9:05 PM, Steven Watanabe <watanabesj_at_[hidden]>
> wrote:
>>
>> AMDG
>>
>> Tang Jiang Jun wrote:
>>>
>>> After thinking deeper, I figure out a rough implementation for this idea,
>>> and prove it can work with polymorphism. (It is just rough concept
>>> verification, and need a lot of work to polish it and make it usable).
>>>
>>
>> A more automated way would be to use
>> multiple inheritance and cross cast.
>>
>> class any_impl_base {
>> public:
>>   virtual ~any_impl_base() {}
>> };
>>
>> template<class T, bool is_class = boost::is_class<T>::value>
>> class any_impl : public T, public any_impl_base {};
>>
>> In Christ,
>> Steven Watanabe
>>
>> _______________________________________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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