Sacado_mpl_bind.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef SACADO_MPL_BIND_HPP
00033 #define SACADO_MPL_BIND_HPP
00034 
00035 #include "Sacado_mpl_placeholders.hpp"
00036 #include "Sacado_mpl_is_same.hpp"
00037 #include "Sacado_mpl_apply_wrap.hpp"
00038 
00039 namespace Sacado {
00040 
00041   namespace mpl {
00042 
00043     template <int k, class F, class T1, class T2, class T3, class T4, class T5>
00044     struct hk { typedef F type; };
00045 
00046     template <int k, int N, class T1, class T2, class T3, class T4, class T5> 
00047     struct hk<k,arg<N>,T1,T2,T3,T4,T5> : 
00048       apply_wrap<arg<N>,T1,T2,T3,T4,T5> {};
00049 
00050     template <int k, class T1, class T2, class T3, class T4, class T5> 
00051     struct hk<k,arg<-1>,T1,T2,T3,T4,T5> : 
00052       apply_wrap<arg<k>,T1,T2,T3,T4,T5> {};
00053 
00054     template <class F, class T1>
00055     struct bind1 {
00056       template <class U1=mpl::none, 
00057                 class U2=mpl::none, 
00058                 class U3=mpl::none, 
00059                 class U4=mpl::none, 
00060                 class U5=mpl::none> 
00061       struct apply : 
00062         apply_wrap1<F,
00063                     typename hk<is_same<T1,placeholders::_>::value,
00064                                 T1,
00065                                 U1,U2,U3,U4,U5>::type> {};
00066     };
00067 
00068     template <class F, class T1, class T2>
00069     struct bind2 {
00070       template <class U1=mpl::none, 
00071                 class U2=mpl::none, 
00072                 class U3=mpl::none, 
00073                 class U4=mpl::none, 
00074                 class U5=mpl::none> 
00075       struct apply : 
00076         apply_wrap2<F,
00077                     typename hk<is_same<T1,placeholders::_>::value,
00078                                 T1,
00079                                 U1,U2,U3,U4,U5>::type,
00080                     typename hk<is_same<T1,placeholders::_>::value+
00081                                 is_same<T2,placeholders::_>::value,
00082                                 T2,
00083                                 U1,U2,U3,U4,U5>::type> {};
00084     };
00085 
00086     template <class F, class T1, class T2, class T3>
00087     struct bind3 {
00088       template <class U1=mpl::none, 
00089                 class U2=mpl::none, 
00090                 class U3=mpl::none, 
00091                 class U4=mpl::none, 
00092                 class U5=mpl::none> 
00093       struct apply : 
00094         apply_wrap3<F,
00095                     typename hk<is_same<T1,placeholders::_>::value,
00096                                 T1,
00097                                 U1,U2,U3,U4,U5>::type,
00098                     typename hk<is_same<T1,placeholders::_>::value+
00099                                 is_same<T2,placeholders::_>::value,
00100                                 T2,
00101                                 U1,U2,U3,U4,U5>::type,
00102                     typename hk<is_same<T1,placeholders::_>::value+
00103                                 is_same<T2,placeholders::_>::value+
00104                                 is_same<T3,placeholders::_>::value,
00105                                 T3,
00106                                 U1,U2,U3,U4,U5>::type> {};
00107     };
00108 
00109     template <class F, class T1, class T2, class T3, class T4>
00110     struct bind4 {
00111       template <class U1=mpl::none, 
00112                 class U2=mpl::none, 
00113                 class U3=mpl::none, 
00114                 class U4=mpl::none, 
00115                 class U5=mpl::none> 
00116       struct apply : 
00117         apply_wrap4<F,
00118                     typename hk<is_same<T1,placeholders::_>::value,
00119                                 T1,
00120                                 U1,U2,U3,U4,U5>::type,
00121                     typename hk<is_same<T1,placeholders::_>::value+
00122                                 is_same<T2,placeholders::_>::value,
00123                                 T2,
00124                                 U1,U2,U3,U4,U5>::type,
00125                     typename hk<is_same<T1,placeholders::_>::value+
00126                                 is_same<T2,placeholders::_>::value+
00127                                 is_same<T3,placeholders::_>::value,
00128                                 T3,
00129                                 U1,U2,U3,U4,U5>::type,
00130                     typename hk<is_same<T1,placeholders::_>::value+
00131                                 is_same<T2,placeholders::_>::value+
00132                                 is_same<T3,placeholders::_>::value+
00133                                 is_same<T4,placeholders::_>::value,
00134                                 T4,
00135                                 U1,U2,U3,U4,U5>::type> {};
00136     };
00137 
00138     template <class F, class T1, class T2, class T3, class T4, class T5>
00139     struct bind5 {
00140       template <class U1=mpl::none, 
00141                 class U2=mpl::none, 
00142                 class U3=mpl::none, 
00143                 class U4=mpl::none, 
00144                 class U5=mpl::none> 
00145       struct apply : 
00146         apply_wrap5<F,
00147                     typename hk<is_same<T1,placeholders::_>::value,
00148                                 T1,
00149                                 U1,U2,U3,U4,U5>::type,
00150                     typename hk<is_same<T1,placeholders::_>::value+
00151                                 is_same<T2,placeholders::_>::value,
00152                                 T2,
00153                                 U1,U2,U3,U4,U5>::type,
00154                     typename hk<is_same<T1,placeholders::_>::value+
00155                                 is_same<T2,placeholders::_>::value+
00156                                 is_same<T3,placeholders::_>::value,
00157                                 T3,
00158                                 U1,U2,U3,U4,U5>::type,
00159                     typename hk<is_same<T1,placeholders::_>::value+
00160                                 is_same<T2,placeholders::_>::value+
00161                                 is_same<T3,placeholders::_>::value+
00162                                 is_same<T4,placeholders::_>::value,
00163                                 T4,
00164                                 U1,U2,U3,U4,U5>::type,
00165                     typename hk<is_same<T1,placeholders::_>::value+
00166                                 is_same<T2,placeholders::_>::value+
00167                                 is_same<T3,placeholders::_>::value+
00168                                 is_same<T4,placeholders::_>::value+
00169                                 is_same<T5,placeholders::_>::value,
00170                                 T5,
00171                                 U1,U2,U3,U4,U5>::type> {};
00172     };
00173 
00174   } // namespace mpl
00175 
00176 } // namespace Sacado
00177 
00178 #endif // SACADO_MPL_BIND_HPP

Generated on Wed May 12 21:39:35 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7