stl.h

Go to the documentation of this file.
00001 00004 /* 00005 * Copyright © 2001 Sofus Mortensen 00006 * 00007 * This material is provided "as is", with absolutely no warranty 00008 * expressed or implied. Any use is at your own risk. Permission to 00009 * use or copy this software for any purpose is hereby granted without 00010 * fee, provided the above notices are retained on all copies. 00011 * Permission to modify the code and to distribute modified code is 00012 * granted, provided the above notices are retained, and a notice that 00013 * the code was modified is included with the above copyright notice. 00014 * 00015 * This header is part of comet. 00016 * http://www.lambdasoft.dk/comet 00017 */ 00018 00019 #ifndef COMET_STL_H 00020 #define COMET_STL_H 00021 00022 #include <comet/config.h> 00023 00024 // add identity, select1st, and select2nd. 00025 #if !defined(__SGI_STL_PORT) && !defined(__MINGW32__) 00026 namespace std { 00029 template<typename T> struct identity : public unary_function<T, T> { 00030 T operator()(const T& t) { return t; } 00031 }; 00032 00035 template<typename T> struct select1st : public unary_function<typename T::first_type, T> { 00036 typename T::first_type operator()(const T& t) { return t.first; } 00037 }; 00038 00041 template<typename T> struct select2nd : public unary_function<typename T::second_type, T> { 00042 typename T::second_type operator()(const T& t) { return t.second; } 00043 }; 00044 } 00045 #else 00046 #include <functional> 00047 #endif 00048 00049 template<typename T> class delete_fun : public std::unary_function<T, void> { 00050 public: 00051 void operator()(T& x) { delete x; } 00052 }; 00053 00054 template<typename T> class delete2nd_fun : public std::unary_function<T, void> { 00055 public: 00056 void operator()(T& x) { delete x.second; } 00057 }; 00058 00059 template<typename T> class delete1st_fun : public std::unary_function<T, void> { 00060 public: 00061 void operator()(T& x) { delete x.first; } 00062 }; 00063 00064 00065 00066 #endif