Chris@16
|
1 /*-----------------------------------------------------------------------------+
|
Chris@16
|
2 Copyright (c) 2007-2009: Joachim Faulhaber
|
Chris@16
|
3 +------------------------------------------------------------------------------+
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
5 (See accompanying file LICENCE.txt or copy at
|
Chris@16
|
6 http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 +-----------------------------------------------------------------------------*/
|
Chris@16
|
8 #ifndef BOOST_ICL_FUNCTORS_HPP_JOFA_080315
|
Chris@16
|
9 #define BOOST_ICL_FUNCTORS_HPP_JOFA_080315
|
Chris@16
|
10
|
Chris@16
|
11 #include <functional>
|
Chris@16
|
12 #include <boost/type_traits.hpp>
|
Chris@16
|
13 #include <boost/mpl/if.hpp>
|
Chris@16
|
14 #include <boost/icl/type_traits/identity_element.hpp>
|
Chris@16
|
15 #include <boost/icl/type_traits/unit_element.hpp>
|
Chris@16
|
16 #include <boost/icl/type_traits/is_set.hpp>
|
Chris@16
|
17 #include <boost/icl/type_traits/has_set_semantics.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 namespace boost{namespace icl
|
Chris@16
|
20 {
|
Chris@16
|
21 // ------------------------------------------------------------------------
|
Chris@16
|
22 template <typename Type> struct identity_based_inplace_combine
|
Chris@16
|
23 : public std::binary_function<Type&, const Type&, void>
|
Chris@16
|
24 {
|
Chris@16
|
25 inline static Type identity_element() { return boost::icl::identity_element<Type>::value(); }
|
Chris@16
|
26 };
|
Chris@16
|
27
|
Chris@16
|
28 // ------------------------------------------------------------------------
|
Chris@16
|
29 template <typename Type> struct unit_element_based_inplace_combine
|
Chris@16
|
30 : public std::binary_function<Type&, const Type&, void>
|
Chris@16
|
31 {
|
Chris@16
|
32 inline static Type identity_element() { return boost::icl::unit_element<Type>::value(); }
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 // ------------------------------------------------------------------------
|
Chris@16
|
36 template <typename Type> struct inplace_identity
|
Chris@16
|
37 : public identity_based_inplace_combine<Type>
|
Chris@16
|
38 {
|
Chris@16
|
39 typedef inplace_identity<Type> type;
|
Chris@16
|
40 void operator()(Type&, const Type&)const{}
|
Chris@16
|
41 };
|
Chris@16
|
42
|
Chris@16
|
43 template<>
|
Chris@16
|
44 inline std::string unary_template_to_string<inplace_identity>::apply()
|
Chris@16
|
45 { return "i="; }
|
Chris@16
|
46
|
Chris@16
|
47 // ------------------------------------------------------------------------
|
Chris@16
|
48 template <typename Type> struct inplace_erasure
|
Chris@16
|
49 : public identity_based_inplace_combine<Type>
|
Chris@16
|
50 {
|
Chris@16
|
51 typedef inplace_erasure<Type> type;
|
Chris@16
|
52 typedef identity_based_inplace_combine<Type> base_type;
|
Chris@16
|
53
|
Chris@16
|
54 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
55 {
|
Chris@16
|
56 if(object == operand)
|
Chris@16
|
57 //identity_element(); //JODO Old gcc-3.4.4 does not compile this
|
Chris@16
|
58 object = base_type::identity_element(); //<-- but this.
|
Chris@16
|
59 }
|
Chris@16
|
60 };
|
Chris@16
|
61
|
Chris@16
|
62 template<>
|
Chris@16
|
63 inline std::string unary_template_to_string<inplace_erasure>::apply()
|
Chris@16
|
64 { return "0="; }
|
Chris@16
|
65
|
Chris@16
|
66 // ------------------------------------------------------------------------
|
Chris@16
|
67 template <typename Type> struct inplace_plus
|
Chris@16
|
68 : public identity_based_inplace_combine<Type>
|
Chris@16
|
69 {
|
Chris@16
|
70 typedef inplace_plus<Type> type;
|
Chris@16
|
71
|
Chris@16
|
72 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
73 { object += operand; }
|
Chris@16
|
74
|
Chris@16
|
75 static void version(Type&){}
|
Chris@16
|
76 };
|
Chris@16
|
77
|
Chris@16
|
78 template<>
|
Chris@16
|
79 inline std::string unary_template_to_string<inplace_plus>::apply() { return "+="; }
|
Chris@16
|
80
|
Chris@16
|
81 // ------------------------------------------------------------------------
|
Chris@16
|
82 template <typename Type> struct inplace_minus
|
Chris@16
|
83 : public identity_based_inplace_combine<Type>
|
Chris@16
|
84 {
|
Chris@16
|
85 typedef inplace_minus<Type> type;
|
Chris@16
|
86
|
Chris@16
|
87 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
88 { object -= operand; }
|
Chris@16
|
89 };
|
Chris@16
|
90
|
Chris@16
|
91 template<>
|
Chris@16
|
92 inline std::string unary_template_to_string<inplace_minus>::apply() { return "-="; }
|
Chris@16
|
93
|
Chris@16
|
94 // ------------------------------------------------------------------------
|
Chris@16
|
95 template <typename Type> struct inplace_bit_add
|
Chris@16
|
96 : public identity_based_inplace_combine<Type>
|
Chris@16
|
97 {
|
Chris@16
|
98 typedef inplace_bit_add<Type> type;
|
Chris@16
|
99
|
Chris@16
|
100 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
101 { object |= operand; }
|
Chris@16
|
102
|
Chris@16
|
103 static void version(Type&){}
|
Chris@16
|
104 };
|
Chris@16
|
105
|
Chris@16
|
106 template<>
|
Chris@16
|
107 inline std::string unary_template_to_string<inplace_bit_add>::apply() { return "b|="; }
|
Chris@16
|
108
|
Chris@16
|
109 // ------------------------------------------------------------------------
|
Chris@16
|
110 template <typename Type> struct inplace_bit_subtract
|
Chris@16
|
111 : public identity_based_inplace_combine<Type>
|
Chris@16
|
112 {
|
Chris@16
|
113 typedef inplace_bit_subtract<Type> type;
|
Chris@16
|
114
|
Chris@16
|
115 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
116 { object &= ~operand; }
|
Chris@16
|
117 };
|
Chris@16
|
118
|
Chris@16
|
119 template<>
|
Chris@16
|
120 inline std::string unary_template_to_string<inplace_bit_subtract>::apply() { return "b-="; }
|
Chris@16
|
121
|
Chris@16
|
122 // ------------------------------------------------------------------------
|
Chris@16
|
123 template <typename Type> struct inplace_bit_and
|
Chris@16
|
124 : public identity_based_inplace_combine<Type>
|
Chris@16
|
125 {
|
Chris@16
|
126 typedef inplace_bit_and<Type> type;
|
Chris@16
|
127
|
Chris@16
|
128 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
129 { object &= operand; }
|
Chris@16
|
130 };
|
Chris@16
|
131
|
Chris@16
|
132 template<>
|
Chris@16
|
133 inline std::string unary_template_to_string<inplace_bit_and>::apply() { return "b&="; }
|
Chris@16
|
134
|
Chris@16
|
135 // ------------------------------------------------------------------------
|
Chris@16
|
136 template <typename Type> struct inplace_bit_xor
|
Chris@16
|
137 : public identity_based_inplace_combine<Type>
|
Chris@16
|
138 {
|
Chris@16
|
139 typedef inplace_bit_xor<Type> type;
|
Chris@16
|
140
|
Chris@16
|
141 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
142 { object ^= operand; }
|
Chris@16
|
143 };
|
Chris@16
|
144
|
Chris@16
|
145 // ------------------------------------------------------------------------
|
Chris@16
|
146 template <typename Type> struct inplace_et
|
Chris@16
|
147 : public identity_based_inplace_combine<Type>
|
Chris@16
|
148 {
|
Chris@16
|
149 typedef inplace_et<Type> type;
|
Chris@16
|
150
|
Chris@16
|
151 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
152 { object &= operand; }
|
Chris@16
|
153 };
|
Chris@16
|
154
|
Chris@16
|
155 template<>
|
Chris@16
|
156 inline std::string unary_template_to_string<inplace_et>::apply() { return "&="; }
|
Chris@16
|
157
|
Chris@16
|
158 // ------------------------------------------------------------------------
|
Chris@16
|
159 template <typename Type> struct inplace_caret
|
Chris@16
|
160 : public identity_based_inplace_combine<Type>
|
Chris@16
|
161 {
|
Chris@16
|
162 typedef inplace_caret<Type> type;
|
Chris@16
|
163
|
Chris@16
|
164 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
165 { object ^= operand; }
|
Chris@16
|
166 };
|
Chris@16
|
167
|
Chris@16
|
168 template<>
|
Chris@16
|
169 inline std::string unary_template_to_string<inplace_caret>::apply() { return "^="; }
|
Chris@16
|
170
|
Chris@16
|
171 // ------------------------------------------------------------------------
|
Chris@16
|
172 template <typename Type> struct inplace_insert
|
Chris@16
|
173 : public identity_based_inplace_combine<Type>
|
Chris@16
|
174 {
|
Chris@16
|
175 typedef inplace_insert<Type> type;
|
Chris@16
|
176
|
Chris@16
|
177 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
178 { insert(object,operand); }
|
Chris@16
|
179 };
|
Chris@16
|
180
|
Chris@16
|
181 template<>
|
Chris@16
|
182 inline std::string unary_template_to_string<inplace_insert>::apply() { return "ins="; }
|
Chris@16
|
183
|
Chris@16
|
184 // ------------------------------------------------------------------------
|
Chris@16
|
185 template <typename Type> struct inplace_erase
|
Chris@16
|
186 : public identity_based_inplace_combine<Type>
|
Chris@16
|
187 {
|
Chris@16
|
188 typedef inplace_erase<Type> type;
|
Chris@16
|
189
|
Chris@16
|
190 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
191 { erase(object,operand); }
|
Chris@16
|
192 };
|
Chris@16
|
193
|
Chris@16
|
194 template<>
|
Chris@16
|
195 inline std::string unary_template_to_string<inplace_erase>::apply() { return "ers="; }
|
Chris@16
|
196
|
Chris@16
|
197 // ------------------------------------------------------------------------
|
Chris@16
|
198 template <typename Type> struct inplace_star
|
Chris@16
|
199 : public identity_based_inplace_combine<Type> //JODO unit_element_
|
Chris@16
|
200 {
|
Chris@16
|
201 typedef inplace_star<Type> type;
|
Chris@16
|
202
|
Chris@16
|
203 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
204 { object *= operand; }
|
Chris@16
|
205 };
|
Chris@16
|
206
|
Chris@16
|
207 template<>
|
Chris@16
|
208 inline std::string unary_template_to_string<inplace_star>::apply() { return "*="; }
|
Chris@16
|
209
|
Chris@16
|
210 // ------------------------------------------------------------------------
|
Chris@16
|
211 template <typename Type> struct inplace_slash
|
Chris@16
|
212 : public identity_based_inplace_combine<Type> //JODO unit_element_
|
Chris@16
|
213 {
|
Chris@16
|
214 typedef inplace_slash<Type> type;
|
Chris@16
|
215
|
Chris@16
|
216 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
217 { object /= operand; }
|
Chris@16
|
218 };
|
Chris@16
|
219
|
Chris@16
|
220 template<>
|
Chris@16
|
221 inline std::string unary_template_to_string<inplace_slash>::apply() { return "/="; }
|
Chris@16
|
222
|
Chris@16
|
223 // ------------------------------------------------------------------------
|
Chris@16
|
224 template <typename Type> struct inplace_max
|
Chris@16
|
225 : public identity_based_inplace_combine<Type>
|
Chris@16
|
226 {
|
Chris@16
|
227 typedef inplace_max<Type> type;
|
Chris@16
|
228
|
Chris@16
|
229 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
230 {
|
Chris@16
|
231 if(object < operand)
|
Chris@16
|
232 object = operand;
|
Chris@16
|
233 }
|
Chris@16
|
234 };
|
Chris@16
|
235
|
Chris@16
|
236 template<>
|
Chris@16
|
237 inline std::string unary_template_to_string<inplace_max>::apply() { return "max="; }
|
Chris@16
|
238
|
Chris@16
|
239 // ------------------------------------------------------------------------
|
Chris@16
|
240 template <typename Type> struct inplace_min
|
Chris@16
|
241 : public identity_based_inplace_combine<Type>
|
Chris@16
|
242 {
|
Chris@16
|
243 typedef inplace_min<Type> type;
|
Chris@16
|
244
|
Chris@16
|
245 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
246 {
|
Chris@16
|
247 if(object > operand)
|
Chris@16
|
248 object = operand;
|
Chris@16
|
249 }
|
Chris@16
|
250 };
|
Chris@16
|
251
|
Chris@16
|
252 template<>
|
Chris@16
|
253 inline std::string unary_template_to_string<inplace_min>::apply() { return "min="; }
|
Chris@16
|
254
|
Chris@16
|
255 //--------------------------------------------------------------------------
|
Chris@16
|
256 // Inter_section functor
|
Chris@16
|
257 //--------------------------------------------------------------------------
|
Chris@16
|
258 template<class Type> struct inter_section
|
Chris@16
|
259 : public identity_based_inplace_combine<Type>
|
Chris@16
|
260 {
|
Chris@16
|
261 typedef typename boost::mpl::
|
Chris@16
|
262 if_<has_set_semantics<Type>,
|
Chris@16
|
263 icl::inplace_et<Type>,
|
Chris@16
|
264 icl::inplace_plus<Type>
|
Chris@16
|
265 >::type
|
Chris@16
|
266 type;
|
Chris@16
|
267
|
Chris@16
|
268 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
269 {
|
Chris@16
|
270 type()(object, operand);
|
Chris@16
|
271 }
|
Chris@16
|
272 };
|
Chris@16
|
273
|
Chris@16
|
274 //--------------------------------------------------------------------------
|
Chris@16
|
275 // Inverse functor
|
Chris@16
|
276 //--------------------------------------------------------------------------
|
Chris@16
|
277 template<class Functor> struct inverse;
|
Chris@16
|
278
|
Chris@16
|
279 template<class Type>
|
Chris@16
|
280 struct inverse<icl::inplace_plus<Type> >
|
Chris@16
|
281 { typedef icl::inplace_minus<Type> type; };
|
Chris@16
|
282
|
Chris@16
|
283 template<class Type>
|
Chris@16
|
284 struct inverse<icl::inplace_minus<Type> >
|
Chris@16
|
285 { typedef icl::inplace_plus<Type> type; };
|
Chris@16
|
286
|
Chris@16
|
287 template<class Type>
|
Chris@16
|
288 struct inverse<icl::inplace_bit_add<Type> >
|
Chris@16
|
289 { typedef icl::inplace_bit_subtract<Type> type; };
|
Chris@16
|
290
|
Chris@16
|
291 template<class Type>
|
Chris@16
|
292 struct inverse<icl::inplace_bit_subtract<Type> >
|
Chris@16
|
293 { typedef icl::inplace_bit_add<Type> type; };
|
Chris@16
|
294
|
Chris@16
|
295 template<class Type>
|
Chris@16
|
296 struct inverse<icl::inplace_et<Type> >
|
Chris@16
|
297 { typedef icl::inplace_caret<Type> type; };
|
Chris@16
|
298
|
Chris@16
|
299 template<class Type>
|
Chris@16
|
300 struct inverse<icl::inplace_caret<Type> >
|
Chris@16
|
301 { typedef icl::inplace_et<Type> type; };
|
Chris@16
|
302
|
Chris@16
|
303 template<class Type>
|
Chris@16
|
304 struct inverse<icl::inplace_bit_and<Type> >
|
Chris@16
|
305 { typedef icl::inplace_bit_xor<Type> type; };
|
Chris@16
|
306
|
Chris@16
|
307 template<class Type>
|
Chris@16
|
308 struct inverse<icl::inplace_bit_xor<Type> >
|
Chris@16
|
309 { typedef icl::inplace_bit_and<Type> type; };
|
Chris@16
|
310
|
Chris@16
|
311 template<class Type>
|
Chris@16
|
312 struct inverse<icl::inplace_star<Type> >
|
Chris@16
|
313 { typedef icl::inplace_slash<Type> type; };
|
Chris@16
|
314
|
Chris@16
|
315 template<class Type>
|
Chris@16
|
316 struct inverse<icl::inplace_slash<Type> >
|
Chris@16
|
317 { typedef icl::inplace_star<Type> type; };
|
Chris@16
|
318
|
Chris@16
|
319 template<class Type>
|
Chris@16
|
320 struct inverse<icl::inplace_max<Type> >
|
Chris@16
|
321 { typedef icl::inplace_min<Type> type; };
|
Chris@16
|
322
|
Chris@16
|
323 template<class Type>
|
Chris@16
|
324 struct inverse<icl::inplace_min<Type> >
|
Chris@16
|
325 { typedef icl::inplace_max<Type> type; };
|
Chris@16
|
326
|
Chris@16
|
327 template<class Type>
|
Chris@16
|
328 struct inverse<icl::inplace_identity<Type> >
|
Chris@16
|
329 { typedef icl::inplace_erasure<Type> type; };
|
Chris@16
|
330
|
Chris@16
|
331 // If a Functor
|
Chris@16
|
332 template<class Functor>
|
Chris@16
|
333 struct inverse
|
Chris@16
|
334 {
|
Chris@16
|
335 typedef typename
|
Chris@16
|
336 remove_reference<typename Functor::first_argument_type>::type argument_type;
|
Chris@16
|
337 typedef icl::inplace_erasure<argument_type> type;
|
Chris@16
|
338 };
|
Chris@16
|
339
|
Chris@16
|
340
|
Chris@16
|
341 //--------------------------------------------------------------------------
|
Chris@16
|
342 // Inverse inter_section functor
|
Chris@16
|
343 //--------------------------------------------------------------------------
|
Chris@16
|
344 template<class Type>
|
Chris@16
|
345 struct inverse<icl::inter_section<Type> >
|
Chris@16
|
346 : public identity_based_inplace_combine<Type>
|
Chris@16
|
347 {
|
Chris@16
|
348 typedef typename boost::mpl::
|
Chris@16
|
349 if_<has_set_semantics<Type>,
|
Chris@16
|
350 icl::inplace_caret<Type>,
|
Chris@16
|
351 icl::inplace_minus<Type>
|
Chris@16
|
352 >::type
|
Chris@16
|
353 type;
|
Chris@16
|
354
|
Chris@16
|
355 void operator()(Type& object, const Type& operand)const
|
Chris@16
|
356 {
|
Chris@16
|
357 type()(object, operand);
|
Chris@16
|
358 }
|
Chris@16
|
359 };
|
Chris@16
|
360
|
Chris@16
|
361
|
Chris@16
|
362 //--------------------------------------------------------------------------
|
Chris@16
|
363 // Positive or negative functor trait
|
Chris@16
|
364 //--------------------------------------------------------------------------
|
Chris@16
|
365
|
Chris@16
|
366 // A binary operation - is negative (or inverting) with respect to the
|
Chris@16
|
367 // neutral element iff it yields the inverse element if it is applied to the
|
Chris@16
|
368 // identity element:
|
Chris@16
|
369 // 0 - x = -x
|
Chris@16
|
370 // For a functor that wraps the inplace of op-assign version this is
|
Chris@16
|
371 // equivalent to
|
Chris@16
|
372 //
|
Chris@16
|
373 // T x = ..., y;
|
Chris@16
|
374 // y = Functor::identity_element();
|
Chris@16
|
375 // Functor()(y, x); // y == inverse_of(x)
|
Chris@16
|
376
|
Chris@16
|
377 template<class Functor> struct is_negative;
|
Chris@16
|
378
|
Chris@16
|
379 template<class Functor>
|
Chris@16
|
380 struct is_negative
|
Chris@16
|
381 {
|
Chris@16
|
382 typedef is_negative<Functor> type;
|
Chris@16
|
383 BOOST_STATIC_CONSTANT(bool, value = false);
|
Chris@16
|
384 };
|
Chris@16
|
385
|
Chris@16
|
386 template<class Type>
|
Chris@16
|
387 struct is_negative<icl::inplace_minus<Type> >
|
Chris@16
|
388 {
|
Chris@16
|
389 typedef is_negative type;
|
Chris@16
|
390 BOOST_STATIC_CONSTANT(bool, value = true);
|
Chris@16
|
391 };
|
Chris@16
|
392
|
Chris@16
|
393 template<class Type>
|
Chris@16
|
394 struct is_negative<icl::inplace_bit_subtract<Type> >
|
Chris@16
|
395 {
|
Chris@16
|
396 typedef is_negative type;
|
Chris@16
|
397 BOOST_STATIC_CONSTANT(bool, value = true);
|
Chris@16
|
398 };
|
Chris@16
|
399
|
Chris@16
|
400 //--------------------------------------------------------------------------
|
Chris@16
|
401 // Pro- or in-version functor
|
Chris@16
|
402 //--------------------------------------------------------------------------
|
Chris@16
|
403 template<class Combiner> struct conversion;
|
Chris@16
|
404
|
Chris@16
|
405 template<class Combiner>
|
Chris@16
|
406 struct conversion
|
Chris@16
|
407 {
|
Chris@16
|
408 typedef conversion<Combiner> type;
|
Chris@16
|
409 typedef typename
|
Chris@16
|
410 remove_const<
|
Chris@16
|
411 typename remove_reference<typename Combiner::first_argument_type
|
Chris@16
|
412 >::type
|
Chris@16
|
413 >::type
|
Chris@16
|
414 argument_type;
|
Chris@16
|
415 // The proversion of an op-assign functor o= lets the value unchanged
|
Chris@16
|
416 // (0 o= x) == x;
|
Chris@16
|
417 // Example += : (0 += x) == x
|
Chris@16
|
418 static argument_type proversion(const argument_type& value)
|
Chris@16
|
419 {
|
Chris@16
|
420 return value;
|
Chris@16
|
421 }
|
Chris@16
|
422
|
Chris@16
|
423 // The inversion of an op-assign functor o= inverts the value x
|
Chris@16
|
424 // to it's inverse element -x
|
Chris@16
|
425 // (0 o= x) == -x;
|
Chris@16
|
426 // Example -= : (0 -= x) == -x
|
Chris@16
|
427 static argument_type inversion(const argument_type& value)
|
Chris@16
|
428 {
|
Chris@16
|
429 argument_type inverse = Combiner::identity_element();
|
Chris@16
|
430 Combiner()(inverse, value);
|
Chris@16
|
431 return inverse;
|
Chris@16
|
432 }
|
Chris@16
|
433 };
|
Chris@16
|
434
|
Chris@16
|
435 template<class Combiner> struct version : public conversion<Combiner>
|
Chris@16
|
436 {
|
Chris@16
|
437 typedef version<Combiner> type;
|
Chris@16
|
438 typedef conversion<Combiner> base_type;
|
Chris@16
|
439 typedef typename base_type::argument_type argument_type;
|
Chris@16
|
440
|
Chris@16
|
441 argument_type operator()(const argument_type& value)
|
Chris@16
|
442 { return base_type::proversion(value); }
|
Chris@16
|
443 };
|
Chris@16
|
444
|
Chris@16
|
445 template<>struct version<icl::inplace_minus<short > >{short operator()(short val){return -val;}};
|
Chris@16
|
446 template<>struct version<icl::inplace_minus<int > >{int operator()(int val){return -val;}};
|
Chris@16
|
447 template<>struct version<icl::inplace_minus<long > >{long operator()(long val){return -val;}};
|
Chris@16
|
448 template<>struct version<icl::inplace_minus<long long > >{long long operator()(long long val){return -val;}};
|
Chris@16
|
449 template<>struct version<icl::inplace_minus<float > >{float operator()(float val){return -val;}};
|
Chris@16
|
450 template<>struct version<icl::inplace_minus<double > >{double operator()(double val){return -val;}};
|
Chris@16
|
451 template<>struct version<icl::inplace_minus<long double> >{long double operator()(long double val){return -val;}};
|
Chris@16
|
452
|
Chris@16
|
453 template<class Type>
|
Chris@16
|
454 struct version<icl::inplace_minus<Type> > : public conversion<icl::inplace_minus<Type> >
|
Chris@16
|
455 {
|
Chris@16
|
456 typedef version<icl::inplace_minus<Type> > type;
|
Chris@16
|
457 typedef conversion<icl::inplace_minus<Type> > base_type;
|
Chris@16
|
458 typedef typename base_type::argument_type argument_type;
|
Chris@16
|
459
|
Chris@16
|
460 Type operator()(const Type& value)
|
Chris@16
|
461 {
|
Chris@16
|
462 return base_type::inversion(value);
|
Chris@16
|
463 }
|
Chris@16
|
464 };
|
Chris@16
|
465
|
Chris@16
|
466 }} // namespace icl boost
|
Chris@16
|
467
|
Chris@16
|
468 #endif
|
Chris@16
|
469
|
Chris@16
|
470
|