Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
TemplateHelpers.hpp
1 
2 #ifndef _TEMPLATE_HELPERS_H_
3 #define _TEMPLATE_HELPERS_H_
4 
5 /**
6  * Template to enforce that a template paramater T is a dervied class of
7  * (or the class itself) T.
8  *
9  * To use, make a template class inherit Derived_from and pass it the template
10  * template paramater as T and the restricting class as B.
11  */
12 template<class T, class B> struct Derived_from {
13  static void constraints(T* p) {
14  B* pb = p;
15  }
16  Derived_from() {
17  void(*p)(T*) = constraints;
18  }
19 };
20 
21 #endif