DGtal  0.9.2
CUnaryFunctor.h
1 
17 #pragma once
18 
30 #if defined(CUnaryFunctor_RECURSES)
31 #error Recursive header files inclusion detected in CUnaryFunctor.h
32 #else // defined(CUnaryFunctor_RECURSES)
33 
34 #define CUnaryFunctor_RECURSES
35 
36 #if !defined CUnaryFunctor_h
37 
38 #define CUnaryFunctor_h
39 
41 // Inclusions
42 #include <iostream>
43 #include "DGtal/base/Common.h"
44 #include "DGtal/base/ConceptUtils.h"
46 
47 namespace DGtal
48 {
49  namespace concepts
50  {
52  // class CUnaryFunctor
88  template <typename X, typename A, typename R>
90  {
91 
92  // ----------------------- Concept checks ------------------------------
93  public:
94 
96  {
97  // x( a ) returns r.
98  ConceptUtils::sameType( r, x.operator() ( a ) );
99  }
100  // ------------------------- Private Datas --------------------------------
101  private:
102  X x;
103  A a;
104  R r;
105  // ------------------------- Internals ------------------------------------
106  private:
107 
108  }; // end of concept CUnaryFunctor
109 
110  //specialization for references
111  template <typename X, typename A, typename R>
113  {
114 
115  // ----------------------- Concept checks ------------------------------
116  public:
117 
119  {
120  ConceptUtils::sameType( getRef(r), x.operator() ( getRef(a) ) );
121  }
122  // ------------------------- Private Datas --------------------------------
123  private:
124  X x;
125  A a;
126  R r;
127  // ------------------------- Internals ------------------------------------
128  private:
129  template<typename T>
130  T& getRef(T& t)
131  {
132  return t;
133  }
134 
135  }; // end of concept CUnaryFunctor
136  }
137 } // namespace DGtal
138 
139 // //
141 
142 #endif // !defined CUnaryFunctor_h
143 
144 #undef CUnaryFunctor_RECURSES
145 #endif // else defined(CUnaryFunctor_RECURSES)
Go to http://www.sgi.com/tech/stl/Assignable.html.
Definition: Boost.dox:32
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89
BOOST_CONCEPT_USAGE(CUnaryFunctor)
Definition: CUnaryFunctor.h:95
void sameType(const T &t1, const T &t2)
DGtal is the top-level namespace which contains all DGtal functions and types.