A collection of handy classes and functions.
More...
|
void | jem::abort (const char *where, const char *what) |
| Prints a message and aborts the current program. More...
|
|
template<class T > |
const T & | jem::min (const T &lhs, const T &rhs) |
| Returns the minimum of two values. More...
|
|
template<class T > |
const T & | jem::max (const T &lhs, const T &rhs) |
| Returns the maximum of two values. More...
|
|
template<class T > |
void | jem::swap (T &lhs, T &rhs) |
| Interchanges two objects. More...
|
|
This header file provides a collection of simple classes and functions that can be used for various purposes. Note that some of these functions (like min
and max
) are also provided by the standard C++ library. They are defined here too so that you do not have to include the rather large header files of the standard library.
void jem::abort |
( |
const char * |
where, |
|
|
const char * |
what |
|
) |
| |
Prints a message to stderr
and aborts the program by calling abort()
. The message is composed of the two parameters where and what.
- Parameters
-
where | - a null-terminated character array that identifies the section of code that calls this function. |
what | - a null-terminated character array that describes why the program is being aborted. |
template<class T >
const T& jem::min |
( |
const T & |
lhs, |
|
|
const T & |
rhs |
|
) |
| |
Returns the minimum of the two values lhs and rhs.
- Parameters
-
lhs | - an object of type T. |
rhs | - another object of type T. |
- Returns
(lhs < rhs) ? lhs : rhs
- Precondition
- The type T implements the
<
operator.
template<class T >
const T& jem::max |
( |
const T & |
lhs, |
|
|
const T & |
rhs |
|
) |
| |
Returns the maximum of the two values lhs and rhs.
- Parameters
-
lhs | - an object of type T. |
rhs | - another object of type T. |
- Returns
(rhs < lhs) ? lhs : rhs
- Precondition
- The type T implements the
<
operator.
template<class T >
void jem::swap |
( |
T & |
lhs, |
|
|
T & |
rhs |
|
) |
| |
The function swap
interchanges its two arguments: lhs becomes rhs, and the other way around.
- Parameters
-
lhs | - an object of type T. |
rhs | - another object of type T. |
- Precondition
- The type T has a default contructor and an assignment operator.