At Sat, 08 Jan 2011 22:29:33 +0100, Paul wrote:
Dave,
Another alternative would be to pass shared/base-ptr's and use double-dispatching to provide functions on concrete types. This however bothers the model-objects with visitation code; which is fine for 1 or 2 things but very disturbing on >10 functions. With the variant you can move the visitation logic completely to the client/caller code, Hopefully its not to vague...?
Your option requires dynacasting
Yes. That's essentially the same problem as extracting an object from a variant. However, yes, if you want typesafe visitation you'd need to build that on top, which essentially replicates logic in visitor. In that case I would consider the shared_ptr<void> approach as a possible future optimization but not a game changer. -- Dave Abrahams BoostPro Computing http://www.boostpro.com