diff --git a/common/helpertemplates.hh b/common/helpertemplates.hh index f65a1e8f6e40b98412a245a6df4fb30e417552b6..2f92627fbc6feb92c5e15fbed0512eaa56b6b29a 100644 --- a/common/helpertemplates.hh +++ b/common/helpertemplates.hh @@ -9,36 +9,40 @@ \brief Compile-time constraint checks from the Stroustrup FAQ */ -/** - Derived_from<A,B>(); - - or - - template<class T> class Container : Derived_from<T,Mybase> { - ... - }; - */ -template<class T, class B> struct Derived_from { - static void constraints(T* p) { B* pb = p; } - Derived_from() { void (*p)(T*) = constraints; } -}; - -/** \todo Please doc me! */ -template<class T1, class T2> struct Can_copy { - static void constraints(T1 a, T2 b) { T2 c = a; b = a; } - Can_copy() { void (*p)(T1,T2) = constraints; } -}; - -/** \todo Please doc me! */ -template<class T1, class T2 = T1> struct Can_compare { - static void constraints(T1 a, T2 b) { a==b; a!=b; a<b; } - Can_compare() { void (*p)(T1,T2) = constraints; } -}; - -/** \todo Please doc me! */ -template<class T1, class T2, class T3 = T1> struct Can_multiply { - static void constraints(T1 a, T2 b, T3 c) { c = a*b; } - Can_multiply() { void (*p)(T1,T2,T3) = constraints; } -}; +namespace Dune { + + /** + Derived_from<A,B>(); + + or + + template<class T> class Container : Derived_from<T,Mybase> { + ... + }; + */ + template<class T, class B> struct Derived_from { + static void constraints(T* p) { B* pb = p; } + Derived_from() { void (*p)(T*) = constraints; } + }; + + /** \todo Please doc me! */ + template<class T1, class T2> struct Can_copy { + static void constraints(T1 a, T2 b) { T2 c = a; b = a; } + Can_copy() { void (*p)(T1,T2) = constraints; } + }; + + /** \todo Please doc me! */ + template<class T1, class T2 = T1> struct Can_compare { + static void constraints(T1 a, T2 b) { a==b; a!=b; a<b; } + Can_compare() { void (*p)(T1,T2) = constraints; } + }; + + /** \todo Please doc me! */ + template<class T1, class T2, class T3 = T1> struct Can_multiply { + static void constraints(T1 a, T2 b, T3 c) { c = a*b; } + Can_multiply() { void (*p)(T1,T2,T3) = constraints; } + }; + +} // namespace Dune #endif