I have some templates of the form:
Where it should only be instantiated if Derived derives from Base. Currently, I'm using a helper template:Code:template < typename Base, typename Derived > void Foo(...)
Then I instantiate a temporary Inherits< Base, Derived >() when I want to check the constraint.Code:template < typename Base, typename Derived > class Inherits { public: Inherits() { Base *b = (Derived *)NULL; } };
Is there a cleverer method?



LinkBack URL
About LinkBacks




CornedBee