ftmpl_functions.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_FUNCTIONS_H
4 #define INCL_FUNCTIONS_H
5 
6 /**
7  *
8  * @file ftmpl_functions.h
9  * some useful template functions.
10  *
11  * Header file corresponds to: nothing
12  *
13  * Hierarchy: bottom, templates
14  *
15  * Developer note:
16  * ---------------
17  * Sooner or later you need them: functions to calculate the
18  * minimum or maximum of two values or the absolute value. Here
19  * they are. All of them are inlined, hence there is no source
20  * file corresponding to `ftmpl_functions.h'.
21  *
22  * The functions are for internal use only (i.e., to build the
23  * library), hence they should not be included from `factory.h'.
24  * However, we have to install `ftmpl_functions.h' with the other
25  * templates since the functions have to be instantiated.
26  *
27 **/
28 
29 // #include <factory/factoryconf.h>
30 
31 /** template <class T> inline T tmax ( const T & a, const T & b )
32  *
33  * tmax() - return the maximum of `a' and `b'.
34  *
35  * Developers note:
36  * ----------------
37  * `T' should have an `operator >()'.
38  *
39 **/
40 template <class T>
41 inline T tmax ( const T & a, const T & b )
42 {
43  return (a > b) ? a : b;
44 }
45 
46 /** template <class T> inline T tmin ( const T & a, const T & b )
47  *
48  * tmin() - return the minimum of `a' and `b'.
49  *
50  * Developers note:
51  * ----------------
52  * `T' should have an `operator <()'.
53  *
54 **/
55 template <class T>
56 inline T tmin ( const T & a, const T & b )
57 {
58  return (a < b) ? a : b;
59 }
60 
61 /** template <class T> inline T tabs ( const T & a )
62  *
63  * tabs() - return the absolute value of `a'.
64  *
65  * `a' is negated iff it is less or equal `T( 0 )'.
66  *
67  * Developers note:
68  * ----------------
69  * `T' should have an `operator >()', an `operator -()', and a
70  * `T::T( int )' constructor.
71  *
72 **/
73 template <class T>
74 inline T tabs ( const T & a )
75 {
76  return (a > T( 0 )) ? a : -a;
77 }
78 
79 #endif /* ! INCL_FUNCTIONS_H */
const poly a
Definition: syzextra.cc:212
T tmin(const T &a, const T &b)
template =""> inline T tmin ( const T & a, const T & b )
T tabs(const T &a)
template =""> inline T tabs ( const T & a )
T tmax(const T &a, const T &b)
template =""> inline T tmax ( const T & a, const T & b )
static jList * T
Definition: janet.cc:37
const poly b
Definition: syzextra.cc:213