Skip to content
Snippets Groups Projects
Commit 2d63694f authored by Oliver Sander's avatar Oliver Sander
Browse files

Helper templates now in namespace Dune. This fixes FlySpray entry 392.

[[Imported from SVN: r5399]]
parent f009976a
Branches
Tags
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment