00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FBTK_COMPOSE_HH
00025 #define FBTK_COMPOSE_HH
00026
00027 #include <functional>
00028
00029 namespace FbTk {
00030
00033 template <class A, class B>
00034 class Compose_base: public std::unary_function<typename B::argument_type, typename A::result_type> {
00035 public:
00036 typedef typename A::result_type ResultTypeA;
00037 typedef typename A::argument_type ArgumentTypeA;
00038 typedef typename B::result_type ResultTypeB;
00039 typedef typename B::argument_type ArgumentTypeB;
00040
00041 Compose_base(const A &a, const B &b):m_a(a), m_b(b) { }
00042 ResultTypeA operator () (const ArgumentTypeB &arg) const {
00043 return m_a(m_b(arg));
00044 }
00045
00046 private:
00047 A m_a;
00048 B m_b;
00049 };
00050
00051
00052 template <typename A, typename B>
00053 inline Compose_base<A, B>
00054 Compose(const A& a, const B& b) {
00055 return Compose_base<A, B>(a, b);
00056 }
00057
00058 }
00059
00060 #endif // FBTK_COMPOSE_HH