$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
exact_gcc_2_95.hh
1 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH
27 # define MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH
28 
33 
34 # include <mln/core/internal/exact.hh>
35 
36 
37 
38 namespace mln
39 {
40 
41  namespace internal
42  {
43 
44  // For exact(T&):
45 
46  template <typename T>
47  struct exact_gcc_2_95
48  {
49  typedef typename mln::internal::exact_<T>::ret E;
50  typedef E& ret;
51  static ret run(T& t)
52  {
53  return *internal::exact_<T>::run(&t);
54  }
55  };
56 
57  template <typename T>
58  struct exact_gcc_2_95< const T >
59  {
60  typedef typename mln::internal::exact_<T>::ret E;
61  typedef const E& ret;
62  static ret run(T& t)
63  {
64  return *internal::exact_<T>::run(const_cast<T*>(&t));
65  }
66  };
67 
68  template <typename T>
69  struct exact_gcc_2_95< T* >
70  {
71  typedef typename mln::internal::exact_<T>::ret E;
72  typedef E* ret;
73  static ret run(T* t)
74  {
75  return internal::exact_<T>::run(t);
76  }
77  };
78 
79  template <typename T>
80  struct exact_gcc_2_95< const T* >
81  {
82  typedef typename mln::internal::exact_<T>::ret E;
83  typedef const E* ret;
84  static ret run(const T* t)
85  {
86  return internal::exact_<T>::run(const_cast<T*>(t));
87  }
88  };
89 
90 
91 
92  // For exact(const T&):
93 
94  template <typename T>
95  struct exact_const_gcc_2_95
96  {
97  typedef typename mln::internal::exact_<T>::ret E;
98  typedef const E& ret;
99  static ret run(T& t)
100  {
101  return *internal::exact_<T>::run(&t);
102  }
103  };
104 
105  template <typename T>
106  struct exact_const_gcc_2_95< const T >
107  {
108  typedef typename mln::internal::exact_<T>::ret E;
109  typedef const E& ret;
110  static ret run(T& t)
111  {
112  return *internal::exact_<T>::run(const_cast<T*>(&t));
113  }
114  };
115 
116  template <typename T>
117  struct exact_const_gcc_2_95< T* >
118  {
119  typedef typename mln::internal::exact_<T>::ret E;
120  typedef E* ret;
121  static ret run(T* t)
122  {
123  return internal::exact_<T>::run(t);
124  }
125  };
126 
127  template <typename T>
128  struct exact_const_gcc_2_95< const T*const >
129  {
130  typedef typename mln::internal::exact_<T>::ret E;
131  typedef const E* ret;
132  static ret run(T* t)
133  {
134  return internal::exact_<T>::run(const_cast<T*>(t));
135  }
136  };
137 
138  template <typename T>
139  struct exact_const_gcc_2_95< const T* >
140  {
141  typedef typename mln::internal::exact_<T>::ret E;
142  typedef const E* ret;
143  static ret run(const T* t)
144  {
145  return internal::exact_<T>::run(const_cast<T*>(t));
146  }
147  };
148 
149 
150  } // end of namespace mln::internal
151 
152 
153 
154  template <typename T>
155  typename internal::exact_gcc_2_95<T>::ret
156  inline
157  exact(T& t)
158  {
159  return internal::exact_gcc_2_95<T>::run(t);
160  }
161 
162  template <typename T>
163  typename internal::exact_const_gcc_2_95<T>::ret
164  inline
165  exact(const T& t)
166  {
167  return internal::exact_const_gcc_2_95<T>::run(const_cast<T&>(t));
168  }
169 
170 
171 
172 } // end of namespace mln
173 
174 #endif // ! MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH