Go to the documentation of this file.00001
00002
00003
00004 #ifndef UTILMM_FUNCTIONAL_UTILS_HEADER
00005 # define UTILMM_FUNCTIONAL_UTILS_HEADER
00006
00007 #include "utilmm/functional/arg_traits.hh"
00008 # include <functional>
00009
00010 namespace utilmm {
00011
00023 template<typename Ty>
00024 struct identity :public std::unary_function<Ty, Ty> {
00025 private:
00026 typedef typename arg_traits<Ty>::type arg_type;
00027
00028 public:
00033 arg_type operator()(arg_type x) const {
00034 return x;
00035 }
00036 };
00037
00049 template<class Pair>
00050 struct select_1st
00051 :public std::unary_function<Pair, typename Pair::first_type> {
00057 typename Pair::first_type const &operator()(Pair const &p) const {
00058 return p.first;
00059 }
00060 };
00061
00073 template<class Pair>
00074 struct select_2nd
00075 :public std::unary_function<Pair, typename Pair::second_type> {
00081 typename Pair::second_type const &operator()(Pair const &p) const {
00082 return p.second;
00083 }
00084 };
00085
00086 }
00087
00088 #endif // UTILMM_FUNCTIONAL_UTILS_HEADER
00089