sprint 1-alpha
|
00001 /****************************************************************************** 00002 * sprint::bind 00003 * 00004 * Copyright (C) 2005-2011 Paolo Medici <www.pmx.it> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 *******************************************************************************/ 00021 00022 #ifndef _SPRINT_FUNCTION_bind_H 00023 #define _SPRINT_FUNCTION_bind_H 00024 00025 // $generated on Oct 30 2011 11:25:25$ 00026 00031 #include <sprint/function/function.h> 00032 #include <sprint/function/detail/adapter.h> 00033 #include <sprint/function/detail/invoker.h> 00034 00035 namespace sprint { 00036 00038 template<class R> 00039 inline function0<R> *bind( R (* fn)()) 00040 { 00041 typedef typename detail::ptr_fun_0<R> invoker_t; 00042 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn) ); 00043 } 00044 00046 template<class R, class P1> 00047 inline function0<R> *bind( R (* fn)(P1), P1 p1) 00048 { 00049 typedef typename detail::ptr_fun_1<R, P1> invoker_t; 00050 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1) ); 00051 } 00052 00054 template<class R, class P1, class P2> 00055 inline function0<R> *bind( R (* fn)(P1, P2), P1 p1, P2 p2) 00056 { 00057 typedef typename detail::ptr_fun_2<R, P1, P2> invoker_t; 00058 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2) ); 00059 } 00060 00062 template<class R, class P1, class P2, class P3> 00063 inline function0<R> *bind( R (* fn)(P1, P2, P3), P1 p1, P2 p2, P3 p3) 00064 { 00065 typedef typename detail::ptr_fun_3<R, P1, P2, P3> invoker_t; 00066 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3) ); 00067 } 00068 00070 template<class R, class P1, class P2, class P3, class P4> 00071 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4), P1 p1, P2 p2, P3 p3, P4 p4) 00072 { 00073 typedef typename detail::ptr_fun_4<R, P1, P2, P3, P4> invoker_t; 00074 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4) ); 00075 } 00076 00078 template<class R, class P1, class P2, class P3, class P4, class P5> 00079 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) 00080 { 00081 typedef typename detail::ptr_fun_5<R, P1, P2, P3, P4, P5> invoker_t; 00082 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5) ); 00083 } 00084 00086 template<class R, class P1, class P2, class P3, class P4, class P5, class P6> 00087 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) 00088 { 00089 typedef typename detail::ptr_fun_6<R, P1, P2, P3, P4, P5, P6> invoker_t; 00090 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6) ); 00091 } 00092 00094 template<class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7> 00095 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6, P7), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) 00096 { 00097 typedef typename detail::ptr_fun_7<R, P1, P2, P3, P4, P5, P6, P7> invoker_t; 00098 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6, p7) ); 00099 } 00100 00102 template<class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> 00103 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6, P7, P8), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) 00104 { 00105 typedef typename detail::ptr_fun_8<R, P1, P2, P3, P4, P5, P6, P7, P8> invoker_t; 00106 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6, p7, p8) ); 00107 } 00108 00110 template<class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9> 00111 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6, P7, P8, P9), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) 00112 { 00113 typedef typename detail::ptr_fun_9<R, P1, P2, P3, P4, P5, P6, P7, P8, P9> invoker_t; 00114 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6, p7, p8, p9) ); 00115 } 00116 00118 template<class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10> 00119 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10) 00120 { 00121 typedef typename detail::ptr_fun_10<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> invoker_t; 00122 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) ); 00123 } 00124 00126 template<class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11> 00127 inline function0<R> *bind( R (* fn)(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11), P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11) 00128 { 00129 typedef typename detail::ptr_fun_11<R, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> invoker_t; 00130 return new detail::adapter0<R, invoker_t >( typename invoker_t::ParamType(fn, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) ); 00131 } 00132 00133 00134 } //sprint 00135 00136 #endif 00137