helpertemplates.hh

Go to the documentation of this file.
00001 // $Id: helpertemplates.hh 5038 2008-01-06 00:59:04Z christi $
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 
00042 #include "static_assert.hh"
00043 
00044 #endif

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].