make_adaptable.hpp

Go to the documentation of this file.
00001 #ifndef BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
00002 #define BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED
00003 
00004 //
00005 //  make_adaptable.hpp
00006 //
00007 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
00008 //
00009 // Distributed under the Boost Software License, Version 1.0. (See
00010 // accompanying file LICENSE_1_0.txt or copy at
00011 // http://www.boost.org/LICENSE_1_0.txt)
00012 //
00013 
00014 namespace boost
00015 {
00016 
00017 namespace _bi
00018 {
00019 
00020 template<class R, class F> class af0
00021 {
00022 public:
00023 
00024     typedef R result_type;
00025 
00026     explicit af0(F f): f_(f)
00027     {
00028     }
00029 
00030     result_type operator()()
00031     {
00032         return f_();
00033     }
00034 
00035     result_type operator()() const
00036     {
00037         return f_();
00038     }
00039 
00040 private:
00041 
00042     F f_;
00043 };
00044 
00045 template<class R, class A1, class F> class af1
00046 {
00047 public:
00048 
00049     typedef R result_type;
00050     typedef A1 argument_type;
00051     typedef A1 arg1_type;
00052 
00053     explicit af1(F f): f_(f)
00054     {
00055     }
00056 
00057     result_type operator()(A1 a1)
00058     {
00059         return f_(a1);
00060     }
00061 
00062     result_type operator()(A1 a1) const
00063     {
00064         return f_(a1);
00065     }
00066 
00067 private:
00068 
00069     F f_;
00070 };
00071 
00072 template<class R, class A1, class A2, class F> class af2
00073 {
00074 public:
00075 
00076     typedef R result_type;
00077     typedef A1 first_argument_type;
00078     typedef A2 second_argument_type;
00079     typedef A1 arg1_type;
00080     typedef A2 arg2_type;
00081 
00082     explicit af2(F f): f_(f)
00083     {
00084     }
00085 
00086     result_type operator()(A1 a1, A2 a2)
00087     {
00088         return f_(a1, a2);
00089     }
00090 
00091     result_type operator()(A1 a1, A2 a2) const
00092     {
00093         return f_(a1, a2);
00094     }
00095 
00096 private:
00097 
00098     F f_;
00099 };
00100 
00101 template<class R, class A1, class A2, class A3, class F> class af3
00102 {
00103 public:
00104 
00105     typedef R result_type;
00106     typedef A1 arg1_type;
00107     typedef A2 arg2_type;
00108     typedef A3 arg3_type;
00109 
00110     explicit af3(F f): f_(f)
00111     {
00112     }
00113 
00114     result_type operator()(A1 a1, A2 a2, A3 a3)
00115     {
00116         return f_(a1, a2, a3);
00117     }
00118 
00119     result_type operator()(A1 a1, A2 a2, A3 a3) const
00120     {
00121         return f_(a1, a2, a3);
00122     }
00123 
00124 private:
00125 
00126     F f_;
00127 };
00128 
00129 template<class R, class A1, class A2, class A3, class A4, class F> class af4
00130 {
00131 public:
00132 
00133     typedef R result_type;
00134     typedef A1 arg1_type;
00135     typedef A2 arg2_type;
00136     typedef A3 arg3_type;
00137     typedef A4 arg4_type;
00138 
00139     explicit af4(F f): f_(f)
00140     {
00141     }
00142 
00143     result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4)
00144     {
00145         return f_(a1, a2, a3, a4);
00146     }
00147 
00148     result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4) const
00149     {
00150         return f_(a1, a2, a3, a4);
00151     }
00152 
00153 private:
00154 
00155     F f_;
00156 };
00157 
00158 } // namespace _bi
00159 
00160 template<class R, class F> _bi::af0<R, F> make_adaptable(F f)
00161 {
00162     return _bi::af0<R, F>(f);
00163 }
00164 
00165 template<class R, class A1, class F> _bi::af1<R, A1, F> make_adaptable(F f)
00166 {
00167     return _bi::af1<R, A1, F>(f);
00168 }
00169 
00170 template<class R, class A1, class A2, class F> _bi::af2<R, A1, A2, F> make_adaptable(F f)
00171 {
00172     return _bi::af2<R, A1, A2, F>(f);
00173 }
00174 
00175 template<class R, class A1, class A2, class A3, class F> _bi::af3<R, A1, A2, A3, F> make_adaptable(F f)
00176 {
00177     return _bi::af3<R, A1, A2, A3, F>(f);
00178 }
00179 
00180 template<class R, class A1, class A2, class A3, class A4, class F> _bi::af4<R, A1, A2, A3, A4, F> make_adaptable(F f)
00181 {
00182     return _bi::af4<R, A1, A2, A3, A4, F>(f);
00183 }
00184 
00185 } // namespace boost
00186 
00187 #endif // #ifndef BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED

Generated on Wed Jan 21 15:32:09 2009 for SystemC by  doxygen 1.5.5