| 1 | // -*- C++ -*- |
| 2 | |
| 3 | #ifndef HL_GCD_H |
| 4 | #define HL_GCD_H |
| 5 | |
| 6 | namespace HL { |
| 7 | |
| 8 | template <int a, int b> |
| 9 | class gcd; |
| 10 | |
| 11 | template <int a> |
| 12 | class gcd<a, 0> |
| 13 | { |
| 14 | public: |
| 15 | enum { VALUE = a }; |
| 16 | static const int value = a; |
| 17 | }; |
| 18 | |
| 19 | template <int a, int b> |
| 20 | class gcd |
| 21 | { |
| 22 | public: |
| 23 | enum { VALUE = gcd<b, a%b>::VALUE }; |
| 24 | static const int value = gcd<b, a%b>::value; |
| 25 | }; |
| 26 | |
| 27 | } |
| 28 | |
| 29 | #endif |