Functions
ftmpl_functions.h File Reference

some useful template functions. More...

Go to the source code of this file.

Functions

template<class T >
T tmax (const T &a, const T &b)
 template <class t>=""> inline T tmax ( const T & a, const T & b ) More...
 
template<class T >
T tmin (const T &a, const T &b)
 template <class t>=""> inline T tmin ( const T & a, const T & b ) More...
 
template<class T >
T tabs (const T &a)
 template <class t>=""> inline T tabs ( const T & a ) More...
 

Detailed Description

some useful template functions.

Header file corresponds to: nothing

Hierarchy: bottom, templates

Developer note:

Sooner or later you need them: functions to calculate the minimum or maximum of two values or the absolute value. Here they are. All of them are inlined, hence there is no source file corresponding to `ftmpl_functions.h'.

The functions are for internal use only (i.e., to build the library), hence they should not be included from `factory.h'. However, we have to install `ftmpl_functions.h' with the other templates since the functions have to be instantiated.

Definition in file ftmpl_functions.h.

Function Documentation

§ tabs()

template<class T >
T tabs ( const T a)
inline

template <class t>=""> inline T tabs ( const T & a )

tabs() - return the absolute value of `a'.

`a' is negated iff it is less or equal `T( 0 )'.

Developers note:

`T' should have an `operator >()', an `operator -()', and a `T::T( int )' constructor.

Definition at line 74 of file ftmpl_functions.h.

75 {
76  return (a > T( 0 )) ? a : -a;
77 }
const poly a
Definition: syzextra.cc:212
static jList * T
Definition: janet.cc:37

§ tmax()

template<class T >
T tmax ( const T a,
const T b 
)
inline

template <class t>=""> inline T tmax ( const T & a, const T & b )

tmax() - return the maximum of `a' and `b'.

Developers note:

`T' should have an `operator >()'.

Definition at line 41 of file ftmpl_functions.h.

42 {
43  return (a > b) ? a : b;
44 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213

§ tmin()

template<class T >
T tmin ( const T a,
const T b 
)
inline

template <class t>=""> inline T tmin ( const T & a, const T & b )

tmin() - return the minimum of `a' and `b'.

Developers note:

`T' should have an `operator <()'.

Definition at line 56 of file ftmpl_functions.h.

57 {
58  return (a < b) ? a : b;
59 }
const poly a
Definition: syzextra.cc:212
const poly b
Definition: syzextra.cc:213