Boost logo

Boost Users :

Subject: Re: [Boost-users] variant: bounded types derive from same base class
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-08-03 09:17:04


On Behalf Of Ovanes Markarian
On behalf of; Igor R [boost.lists_at_[hidden]]
----------------------------------------------------------------------------
-------------------

Thank you for your answers,

But it may be boost::variant is not what I need, but perhaps a different
facility
implementing visitor pattern.

My restriction is that f takes a ABC const-ref as an input.
Can I construct the variant from the const ABC& abc
Maybe like
    variant<D1, D2, ... Dn> v(abc);

without deep copying. The Di objects are big.

Then I would apply the visitation.

Maybe storing variant<D1*, D2*, Dn*>...

So f would look like

void f( const ABC& abc )
{
   const VariantTypeDefProvidedByLib v(&abc);

    v.apply_visitor( YourVisitor );
}

If this works, what is its cost relative to having been able to simply
implement virtual functions in ABC?

Again, thanks for the answers,
Regards,


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