Imre <jr**@pager.hu> wrote:
I'm trying to write a function template called CallF(), that has a type
argument called T. It has one argument, a T*. If T has a member
function F(), then CallF() should call it, otherwise it should do
nothing.
- Is my stuff right according to the standard?
I am not a guru, so I will say only that I imagine that it isn't,
(although VC is not the poster-child for a standard-conforming
implementation).
- Does anyone have a solution / workaround for this that works in VC?
Again, I am not a guru, but I will offer something anyway, since it
seems that the gurus have not yet seen your post. At least one
possibility is to force all the T's that your template accepts to
inherit from a common base class,
class CallFClass
{
public:
virtual void F() {}
};
and then let classes that wish to implement F() do so. I am betting
that there is some common trait shared by the classes you wish to use
your template with, so introducing a common base class might not be a
bad design decision anyway.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.