helpertemplates.hh
Go to the documentation of this file.00001
00002
00003 #ifndef DUNE_COMMON_HELPERTEMPLATES
00004 #define DUNE_COMMON_HELPERTEMPLATES
00005
00010 namespace Dune {
00011
00021 template<class T, class B> struct Derived_from {
00022 static void constraints(T* p) { B* pb = p; }
00023 Derived_from() { void(*p)(T*) = constraints; }
00024 };
00025
00027 template<class T1, class T2> struct Can_copy {
00028 static void constraints(T1 a, T2 b) { T2 c = a; b = a; }
00029 Can_copy() { void(*p)(T1,T2) = constraints; }
00030 };
00031
00033 template<class T1, class T2 = T1> struct Can_compare {
00034 static void constraints(T1 a, T2 b) { a==b; a!=b; a<b; }
00035 Can_compare() { void(*p)(T1,T2) = constraints; }
00036 };
00037
00039 template<class T1, class T2, class T3 = T1> struct Can_multiply {
00040 static void constraints(T1 a, T2 b, T3 c) { c = a*b; }
00041 Can_multiply() { void(*p)(T1,T2,T3) = constraints; }
00042 };
00043
00044 }
00045
00046 #endif