DGtal  1.3.beta
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)
DGtal::concepts::CUnaryFunctor< X, A &, R & >::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(CUnaryFunctor)
Definition: CUnaryFunctor.h:118
DGtal::concepts::CUnaryFunctor< X, A &, R & >::x
X x
Definition: CUnaryFunctor.h:124
DGtal::ProbingMode::R
@ R
DGtal::concepts::CUnaryFunctor::a
A a
Definition: CUnaryFunctor.h:103
DGtal::concepts::CUnaryFunctor< X, A &, R & >::r
R r
Definition: CUnaryFunctor.h:126
DGtal::concepts::CUnaryFunctor< X, A &, R & >::a
A a
Definition: CUnaryFunctor.h:125
DGtal::concepts::CUnaryFunctor::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(CUnaryFunctor)
Definition: CUnaryFunctor.h:95
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::concepts::ConceptUtils::sameType
void sameType(const T &, const T &)
Definition: ConceptUtils.h:117
DGtal::concepts::CUnaryFunctor::x
X x
Definition: CUnaryFunctor.h:102
DGtal::concepts::CUnaryFunctor::r
R r
Definition: CUnaryFunctor.h:104
DGtal::concepts::CUnaryFunctor< X, A &, R & >::getRef
T & getRef(T &t)
Definition: CUnaryFunctor.h:130
boost::Assignable
Go to http://www.sgi.com/tech/stl/Assignable.html.
Definition: Boost.dox:32
DGtal::concepts::CUnaryFunctor
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:89