helpertemplates.hh

Go to the documentation of this file.
00001 // $Id: helpertemplates.hh 4722 2006-10-13 08:59:35Z oliver $
00002 
00003 #ifndef DUNE_COMMON_HELPERTEMPLATES
00004 #define DUNE_COMMON_HELPERTEMPLATES
00005 
00019 template<class T, class B> struct Derived_from {
00020     static void constraints(T* p) { B* pb = p; }
00021     Derived_from() { void(*p)(T*) = constraints; }
00022 };
00023 
00025 template<class T1, class T2> struct Can_copy {
00026     static void constraints(T1 a, T2 b) { T2 c = a; b = a; }
00027     Can_copy() { void(*p)(T1,T2) = constraints; }
00028 };
00029 
00031 template<class T1, class T2 = T1> struct Can_compare {
00032     static void constraints(T1 a, T2 b) { a==b; a!=b; a<b; }
00033     Can_compare() { void(*p)(T1,T2) = constraints; }
00034 };
00035 
00037 template<class T1, class T2, class T3 = T1> struct Can_multiply {
00038     static void constraints(T1 a, T2 b, T3 c) { c = a*b; }
00039     Can_multiply() { void(*p)(T1,T2,T3) = constraints; }
00040 };
00041 
00059 template <bool condition>
00060 struct IsTrue
00061 {
00062   static void no() {};
00063 };
00064 
00065 template <>
00066 struct IsTrue<true>
00067 {
00068   static void yes() {};
00069 };
00070 
00071 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)