[Boost.Any] Are there visitors for boost::any?
Hi all. I was curious to see if there is or will be support for the use of the visitor pattern with boost::any? I think it would be very useful. I thought I had read that there was an experimental boost::any visitor at some point, but I couldn't find it. Please let me know. Thanks. --------------------------------- Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
On 17/07/07, Rydinare
Hi all. I was curious to see if there is or will be support for the use of the visitor pattern with boost::any? I think it would be very useful. I thought I had read that there was an experimental boost::any visitor at some point, but I couldn't find it.
It'd certainly take stronger template-foo than I have. The way I understand it, classic visitor relies on knowing all the possible types, which Boost.Any doesn't. I suppose one could be written using map lookup, but that's more like manually implementing runtime overloading than visitor. ~ Scott
On 18/07/07, Rydinare
Hi all. I was curious to see if there is or will be support for the use of the visitor pattern with boost::any? I think it would be very useful. I thought I had read that there was an experimental boost::any visitor at some point, but I couldn't find it.
Please let me know.
Thanks.
I've done such a thing using a defined set of types and an if..else if chain, using the type() member of any and typeid() to switch on type...however, I *only* did this because it was before Boost.Variant was available. If you have some strict set of types that you're looking for, Boost.Variant would be a better option. Stuart Dootson
participants (3)
-
Rydinare
-
Scott McMurray
-
Stuart Dootson