src/sysc/packages/boost/bind/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 //  Permission to copy, use, modify, sell and distribute this software
00010 //  is granted provided this copyright notice appears in all copies.
00011 //  This software is provided "as is" without express or implied
00012 //  warranty, and with no claim as to its suitability for any purpose.
00013 //
00014 
00015 namespace boost
00016 {
00017 
00018 namespace _bi
00019 {
00020 
00021 template<class F> void instantiate(F)
00022 {
00023 }
00024 
00025 template<class R, class F> class af0
00026 {
00027 public:
00028 
00029     typedef R result_type;
00030 
00031     explicit af0(F f): f_(f)
00032     {
00033     }
00034 
00035     result_type operator()()
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 private:
00063 
00064     F f_;
00065 };
00066 
00067 template<class R, class A1, class A2, class F> class af2
00068 {
00069 public:
00070 
00071     typedef R result_type;
00072     typedef A1 first_argument_type;
00073     typedef A2 second_argument_type;
00074     typedef A1 arg1_type;
00075     typedef A2 arg2_type;
00076 
00077     explicit af2(F f): f_(f)
00078     {
00079     }
00080 
00081     result_type operator()(A1 a1, A2 a2)
00082     {
00083         return f_(a1, a2);
00084     }
00085 
00086 private:
00087 
00088     F f_;
00089 };
00090 
00091 template<class R, class A1, class A2, class A3, class F> class af3
00092 {
00093 public:
00094 
00095     typedef R result_type;
00096     typedef A1 arg1_type;
00097     typedef A2 arg2_type;
00098     typedef A3 arg3_type;
00099 
00100     explicit af3(F f): f_(f)
00101     {
00102     }
00103 
00104     result_type operator()(A1 a1, A2 a2, A3 a3)
00105     {
00106         return f_(a1, a2, a3);
00107     }
00108 
00109 private:
00110 
00111     F f_;
00112 };
00113 
00114 template<class R, class A1, class A2, class A3, class A4, class F> class af4
00115 {
00116 public:
00117 
00118     typedef R result_type;
00119     typedef A1 arg1_type;
00120     typedef A2 arg2_type;
00121     typedef A3 arg3_type;
00122     typedef A4 arg4_type;
00123 
00124     explicit af4(F f): f_(f)
00125     {
00126     }
00127 
00128     result_type operator()(A1 a1, A2 a2, A3 a3, A4 a4)
00129     {
00130         return f_(a1, a2, a3, a4);
00131     }
00132 
00133 private:
00134 
00135     F f_;
00136 };
00137 
00138 } // namespace _bi
00139 
00140 template<class R, class F> _bi::af0<R, F> make_adaptable(F f)
00141 {
00142     _bi::instantiate( &_bi::af0<R, F>::operator() ); // for early error detection
00143     return _bi::af0<R, F>(f);
00144 }
00145 
00146 template<class R, class A1, class F> _bi::af1<R, A1, F> make_adaptable(F f)
00147 {
00148     instantiate( &_bi::af1<R, A1, F>::operator() );
00149     return _bi::af1<R, A1, F>(f);
00150 }
00151 
00152 template<class R, class A1, class A2, class F> _bi::af2<R, A1, A2, F> make_adaptable(F f)
00153 {
00154     instantiate( &_bi::af2<R, A1, A2, F>::operator() );
00155     return _bi::af2<R, A1, A2, F>(f);
00156 }
00157 
00158 template<class R, class A1, class A2, class A3, class F> _bi::af3<R, A1, A2, A3, F> make_adaptable(F f)
00159 {
00160     instantiate( &_bi::af3<R, A1, A2, A3, F>::operator() );
00161     return _bi::af3<R, A1, A2, A3, F>(f);
00162 }
00163 
00164 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)
00165 {
00166     instantiate( &_bi::af4<R, A1, A2, A3, A4, F>::operator() );
00167     return _bi::af4<R, A1, A2, A3, A4, F>(f);
00168 }
00169 
00170 } // namespace boost
00171 
00172 #endif // #ifndef BOOST_BIND_MAKE_ADAPTABLE_HPP_INCLUDED

Generated on Wed Apr 25 13:53:27 2007 for SystemC by  doxygen 1.5.1