DGtal  1.5.beta
ExpressionTemplates.h
1 
17 #pragma once
18 
31 #if defined(ExpressionTemplates_RECURSES)
32 #error Recursive header files inclusion detected in ExpressionTemplates.h
33 #else // defined(ExpressionTemplates_RECURSES)
35 #define ExpressionTemplates_RECURSES
36 
37 #if !defined ExpressionTemplates_h
39 #define ExpressionTemplates_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal
48 {
49 
53  template <int X, unsigned exponent> class POW
54  {
55  public: enum{ VALUE = X* POW<X, exponent-1>::VALUE};
56  };
57  template <int X > class POW<X, 1>
58  {
59  public: enum{ VALUE = X };
60  };
61  template <int X > class POW<X, 0>
62  {
63  public: enum { VALUE = 1 };
64  };
65 
69  template <int X>
70  class LOG2
71  {
72  public: enum{ VALUE = 1 + LOG2<X / 2>::VALUE};
73  };
74  template <> class LOG2<2>
75  {
76  public: enum{ VALUE = 1 };
77  };
78  template <> class LOG2<1>
79  {
80  public: enum{ VALUE = 0 };
81  };} // namespace DGtal
82 
83 
84 // //
86 
87 #endif // !defined ExpressionTemplates_h
88 
89 #undef ExpressionTemplates_RECURSES
90 #endif // else defined(ExpressionTemplates_RECURSES)
DGtal is the top-level namespace which contains all DGtal functions and types.