ucommon

ucommon/generics.h File Reference

Generic templates for C++. More...

#include <ucommon/platform.h>
#include <stdlib.h>
Include dependency graph for generics.h:

Go to the source code of this file.

Data Structures

class  array_pointer< T >
 Generic smart array class. More...
class  pointer< T >
 Generic smart pointer class. More...
class  temp_array< T >
 Manage temporary array stored on the heap. More...
class  temporary< T >
 Manage temporary object stored on the heap. More...

Defines

#define THROW(x)   ::abort()
#define THROWS(x)
#define THROWS_ANY

Functions

template<class T >
bool is (T &object)
 Convenience function to validate object assuming it is castable to bool.
template<class T >
bool isnull (T &object)
 Convenience function to test pointer object.
template<class T >
bool isnullp (T *object)
 Convenience function to test pointer-pointer object.
template<typename T >
T &() max (T &o1, T &o2)
 Convenience function to return max of two objects.
template<typename T >
T &() min (T &o1, T &o2)
 Convenience function to return min of two objects.
template<typename T >
void swap (T &o1, T &o2)
 Convenience function to swap objects.

Detailed Description

Generic templates for C++.

These are templates that do not depend on any ucommon classes. They can be used for generic C++ programming.

Definition in file generics.h.


Function Documentation

template<class T >
bool is ( T &  object) [inline]

Convenience function to validate object assuming it is castable to bool.

Parameters:
objectwe are testing.
Returns:
true if object valid.
Examples:
datetime.cpp, and shell.cpp.

Definition at line 422 of file generics.h.

template<class T >
bool isnull ( T &  object) [inline]

Convenience function to test pointer object.

This solves issues where some compilers get confused between bool and pointer operators.

Parameters:
objectwe are testing.
Returns:
true if object points to NULL.

Definition at line 432 of file generics.h.

template<class T >
bool isnullp ( T *  object) [inline]

Convenience function to test pointer-pointer object.

This solves issues where some compilers get confused between bool and pointer operators.

Parameters:
objectwe are testing.
Returns:
true if object points to NULL.

Definition at line 442 of file generics.h.

template<typename T >
T&() max ( T &  o1,
T &  o2 
) [inline]

Convenience function to return max of two objects.

Parameters:
o1to check.
o2to check.
Returns:
max object.

Definition at line 461 of file generics.h.

template<typename T >
T&() min ( T &  o1,
T &  o2 
) [inline]

Convenience function to return min of two objects.

Parameters:
o1to check.
o2to check.
Returns:
min object.

Definition at line 473 of file generics.h.

template<typename T >
void swap ( T &  o1,
T &  o2 
) [inline]

Convenience function to swap objects.

Parameters:
o1to swap.
o2to swap.

Definition at line 451 of file generics.h.

Here is the call graph for this function: