diff --git a/elementaryxx/src/localUtil.cpp b/elementaryxx/src/localUtil.cpp new file mode 100644 index 0000000..6100b6a --- /dev/null +++ b/elementaryxx/src/localUtil.cpp @@ -0,0 +1,6 @@ +/* Project */ +#include "localUtil.h" + +namespace Elmxx { + +} // end namespace Elmxx \ No newline at end of file diff --git a/elementaryxx/src/localUtil.h b/elementaryxx/src/localUtil.h new file mode 100644 index 0000000..7f8cd13 --- /dev/null +++ b/elementaryxx/src/localUtil.h @@ -0,0 +1,43 @@ +#ifndef ELMXX_LOCAL_UTIL_H +#define ELMXX_LOCAL_UTIL_H + +/* STL */ +#include +#include + +namespace Elmxx { + +// some generic template functions for delete algorithms +template +void delete_one (T *t) +{ + delete t; + t = NULL; +} + +template +void delete_array (T *t) +{ + delete [] t; + t = NULL; +} + +template +struct delete_unary : public std::unary_function +{ + void operator () (T &t) + { + delete t; + } +}; + +template +void delete_stl_container (T &t) +{ + for_each (t.begin (), t.end (), delete_unary ()); + t.clear (); +} + +} // end namespace Elmxx + +#endif // ELMXX_LOCAL_UTIL_H