gcd.hh

Go to the documentation of this file.
00001 #ifndef DUNE_GCD_HH
00002 #define DUNE_GCD_HH
00003 
00004 #include"static_assert.hh"
00005 namespace Dune
00006 {
00020   template<long a, long b, bool bo>
00021   struct GcdHelper
00022   {};
00023   
00024   
00025   template<long a, long b>
00026   struct GcdHelper<a,b,true>
00027   {
00031     static void conceptCheck()
00032     {
00033       dune_static_assert(b<a, "b<a must hold!");
00034       dune_static_assert(0<b, "b must be positive");
00035     }
00036 
00037     
00041      const static long gcd = GcdHelper<b,a%b,true>::gcd;
00042   };
00043   
00044   template<long a, long b>
00045   struct GcdHelper<a,b,false>
00046   {
00050     const static long gcd = GcdHelper<b,a,true>::gcd;
00051   };
00052   template<long a>
00053   struct GcdHelper<a,0,true>
00054   {
00055     const static long gcd=a;
00056   };
00057   
00058   
00062   template<long a, long b>
00063   struct Gcd
00064   {
00067     const static long value = GcdHelper<a,b,(a>b)>::gcd;
00068   };
00069   
00073 }
00074 
00075 #endif

Generated on Sun Nov 15 22:28:13 2009 for dune-common by  doxygen 1.5.6