DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CInteger.h
1 
17 #pragma once
18 
31 #if defined(CInteger_RECURSES)
32 #error Recursive header files inclusion detected in CInteger.h
33 #else // defined(CInteger_RECURSES)
34 
35 #define CInteger_RECURSES
36 
37 #if !defined CInteger_h
38 
39 #define CInteger_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "boost/concept_check.hpp"
45 #include "DGtal/base/ConceptUtils.h"
46 #include "DGtal/base/Common.h"
47 #include "DGtal/kernel/NumberTraits.h"
49 
50 namespace DGtal
51 {
52 
54  // class CInteger
268  template <typename T>
269  struct CInteger : boost::Assignable<T>, boost::EqualityComparable<T>, boost::LessThanComparable<T>
270  {
271  // ----------------------- Concept checks ------------------------------
272  public:
274  {
275  T x( 0 ); // require constructor from built-in integer.
276  T y( 1 ); // require constructor from built-in integer.
277  ConceptUtils::sameType( myX, ++x );
278  ConceptUtils::sameType( myX, --x );
281 
282  // @note x-y with short is promoted to int. We should use some
283  // verification with possible promoting.
284  //
285  // @note T(x-y) is required (instead of 'x-y') because of
286  // gmpxx. Indeed, x+y returns an expression template in GMP and
287  // thus cannot be of type T.
288  ConceptUtils::sameType( myX, T(x-y) );
289  // @note x+y with short is promoted to int. We should use some
290  // verification with possible promoting.
291  //
292  // @note T(x+y) is required (instead of 'x+y') because of
293  // gmpxx. Indeed, x+y returns an expression template in GMP and
294  // thus cannot be of type T.
295  ConceptUtils::sameType( myX, T(x+y) );
296  ConceptUtils::sameType( myX, T(x*y) );
297  ConceptUtils::sameType( myX, T(x/y) );
298  ConceptUtils::sameType( myX, T(x%y) );
299  }
300 
301  // ------------------------- Private Datas --------------------------------
302  private:
303  T myX;
310 
314 
315  // ------------------------- Internals ------------------------------------
316  private:
317 
318  }; // end of concept CInteger
319 
320 } // namespace DGtal
321 
322 // //
324 
325 #endif // !defined CInteger_h
326 
327 #undef CInteger_RECURSES
328 #endif // else defined(CInteger_RECURSES)