|
Boost Users : |
Subject: Re: [Boost-users] boost variant question
From: petros (pmamales_at_[hidden])
Date: 2011-09-25 12:15:07
Hi Igor,
Thank you very much,
Best Regards,
Petros
-----Original Message-----
From: Igor R
Sent: Sunday, September 25, 2011 3:05 AM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] boost variant question
> I am not sure that I understand it though.
> I have seen examples (wrote a couple myself) where, using the
> static_visitor,
> "dictated" the behavior of public member functions of the variant type.
> But which iterator type to associate with the hosted type would require a
> variant of iterators to be maintaned along-side. Is this what you mean? If
> not, is there an example or
> "sketchy" pseudo code you could point me too.
Sorry, perhaps I misunderstood you. Lets say you've got the following:
variant<container1, container2> var;
Do you mean to use it like this:
iterator1 it = your_begin(var);
do_something(it);
If so, you have to know "iterator1" type in compile-time - this is the
problem, isn't it?
Of course, you can find out it with "try and fail" approach, using
get() function template, but this would be ugly and hard to support.
That's why typically one moves do_something (i.e. anything that
depends on the actual container type) to the visitor itself.
_______________________________________________
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