|
Boost : |
From: Trenton Tuggle (Tuggle_at_[hidden])
Date: 2002-04-19 13:15:40
Hello,
I've been staring at the code of any for some while now. I'd like to
make it visitable, *and* have the visitor type be a function template,
instead of specializing the whole any class on the visitor type.
It seems to me that's impossible, but I was wondering if anyone saw
something I didn't!
Here's the gist:
class any
{
template <class Visitor> void accept(Visitor v)
{
held->accept(v); // can't be done polymorphically!
}
};
the problem is that virtual functions can't be templated! How can I
call the specific PlaceHolder's accept, passing it the specific visitor,
when you can't call a templated function virtually!
It's useless to wrap the visitor with a template derriving from a
polymorphic base class: you can then pass the wrapped visitor, but you
can't call back the specific visit() specialization, or get to the
specific visitor from the specific PlaceHolder!
Maybe I'm missing something! Has anyone else tried this?
Thanks,
Trent Tuggle
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk