I
IR
Hi,
Still playing around with templates, I have the following
questions...
I know how to express "positive" compile time assertions of a
class's interface in templates (ie. T has-a member with this
signature), using a syntax similar to:
template<class T>
struct InterfaceEnforcer
{
InterfaceEnforcer()
{
void (T::*sig1)() const = &T::Function1;
};
};
and inheriting from (or declaring a variable of type)
InterfaceEnforcer<MyClass>
I would like to know if it is possible to:
1) make a "partial" interface check on T, something like:
template<class T, class U>
struct InterfaceEnforcer
{
InterfaceEnforcer()
{
U (T::*sig1)() const = &T::Function1;
};
};
but this very syntax (and others I tried around the same idea)
doesn't work.
2) check that a specific member does NOT exist in T. I don't even
have an idea of how to express this concept. I don't think it is
possible, but would value a confirmation.
Any ideas anyone?
Thanks in advance.
Still playing around with templates, I have the following
questions...
I know how to express "positive" compile time assertions of a
class's interface in templates (ie. T has-a member with this
signature), using a syntax similar to:
template<class T>
struct InterfaceEnforcer
{
InterfaceEnforcer()
{
void (T::*sig1)() const = &T::Function1;
};
};
and inheriting from (or declaring a variable of type)
InterfaceEnforcer<MyClass>
I would like to know if it is possible to:
1) make a "partial" interface check on T, something like:
template<class T, class U>
struct InterfaceEnforcer
{
InterfaceEnforcer()
{
U (T::*sig1)() const = &T::Function1;
};
};
but this very syntax (and others I tried around the same idea)
doesn't work.
2) check that a specific member does NOT exist in T. I don't even
have an idea of how to express this concept. I don't think it is
possible, but would value a confirmation.
Any ideas anyone?
Thanks in advance.