📄 afunction_ext.hpp
字号:
// In order to use functions with more than 3 parameters, new classes (OneOperator4_, OneOperator5_, etc.) must// be defined. See example code in include/AFunction.hpp// Two classes must be defined (here we show an example for a function accepting 4 arguments)://// class OneOperator4_ // class E_F_F0F0F0F0_//// Note: in file includeAFunction.hpp, the class "OneOperator" (around line 400) mut be modified.// ***********************************************// **** 4 parameters// ***********************template<class R,class A0,class A1,class A2, class A3, class E=E_F0> // extend (4th arg.)class E_F_F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 & ) ; // extend (4th arg.) func f; Expression a0,a1,a2,a3; // extend E_F_F0F0F0F0_(func ff, Expression aa0, Expression aa1, Expression aa2, Expression aa3) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3) {} // extend (4th arg.) AnyType operator()(Stack s) const {return SetAny<R>( f( GetAny<A0>((*a0)(s)), GetAny<A1>((*a1)(s)), GetAny<A2>((*a2)(s)), GetAny<A3>((*a3)(s)) ) );} // extend (4th arg.) virtual size_t nbitem() const {return a3->nbitem(); } // modif bool MeshIndependent() const {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent()&& a3->MeshIndependent();} // extend (4th arg.)};template<class R,class A=R,class B=A,class C=B, class D=C ,class CODE=E_F_F0F0F0F0_<R,A,B,C,D,E_F0> > // extend (4th arg.)class OneOperator4_ : public OneOperator { // 3->4 aType r; // return type typedef typename CODE::func func; func f;public: E_F0 * code(const basicAC_F0 & args) const { return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]));} // extend OneOperator4_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], map_type[typeid(A).name()], map_type[typeid(B).name()], map_type[typeid(C).name()], map_type[typeid(D).name()]), // extens f(ff){}};// ***********************************************// **** 5 parameters// ***********************//// NOTE: add the following line in AFunction.hpp//// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e) // : r(rr),ArrayOfaType(a,b,c,d,e,false),next(0),pref(0) {throwassert(rr && a && b && c && d);} template<class R,class A0,class A1,class A2, class A3, class A4, class E=E_F0> // extend AXclass E_F_F0F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 & ) ; // extend AX func f; Expression a0,a1,a2,a3,a4; // extend aX E_F_F0F0F0F0F0_(func ff, // extend F0 Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4) {} // extend aX AnyType operator()(Stack s) const {return SetAny<R>( f( GetAny<A0>((*a0)(s)), GetAny<A1>((*a1)(s)), GetAny<A2>((*a2)(s)), GetAny<A3>((*a3)(s)), GetAny<A4>((*a4)(s)) ) );} // extend aX virtual size_t nbitem() const {return a4->nbitem(); } bool MeshIndependent() const {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() && a3->MeshIndependent()&& a4->MeshIndependent();} // extend aX};template<class R,class A=R,class B=A,class C=B, class D=C ,class E=D ,class CODE=E_F_F0F0F0F0F0_<R,A,B,C,D,E,E_F0> > // extend class OneOperator5_ : public OneOperator { // 3->4 aType r; // return type typedef typename CODE::func func; func f;public: E_F0 * code(const basicAC_F0 & args) const { return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]));} // extend OneOperator5_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], map_type[typeid(A).name()], map_type[typeid(B).name()], map_type[typeid(C).name()], map_type[typeid(D).name()], map_type[typeid(E).name()]), // extend f(ff){}};// ***********************************************// **** 6 parameters// ***********************//// NOTE: add the following line in AFunction.hpp// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) // : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} template<class R,class A0,class A1,class A2, class A3, class A4, class A5, class E=E_F0> // extend AXclass E_F_F0F0F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 & ) ; // extend AX func f; Expression a0,a1,a2,a3,a4,a5; // extend aX E_F_F0F0F0F0F0F0_(func ff, // extend F0 Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4, Expression aa5) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5) {} // extend aX AnyType operator()(Stack s) const {return SetAny<R>( f( GetAny<A0>((*a0)(s)), GetAny<A1>((*a1)(s)), GetAny<A2>((*a2)(s)), GetAny<A3>((*a3)(s)), GetAny<A4>((*a4)(s)), GetAny<A5>((*a5)(s)) ) );} // extend aX virtual size_t nbitem() const {return a5->nbitem(); } bool MeshIndependent() const {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent();} // extend aX};template<class R,class A=R,class B=A,class C=B, class D=C ,class E=D ,class F=E ,class CODE=E_F_F0F0F0F0F0F0_<R,A,B,C,D,E,F,E_F0> > // extend class OneOperator6_ : public OneOperator { // 3->4 aType r; // return type typedef typename CODE::func func; func f;public: E_F0 * code(const basicAC_F0 & args) const { return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5]));} // extend OneOperator6_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], map_type[typeid(A).name()], map_type[typeid(B).name()], map_type[typeid(C).name()], map_type[typeid(D).name()], map_type[typeid(E).name()], map_type[typeid(F).name()]), // extend f(ff){}};// ***********************************************// **** 7 parameters// ***********************//// NOTE: add the following line in AFunction.hpp// OneOperator(aType rr,aType a,aType b,aType c,aType d,aType e,aType f) // : r(rr),ArrayOfaType(a,b,c,d,e,f,false),next(0),pref(0) {throwassert(rr && a && b && c && d && f);} template<class R,class A0,class A1,class A2, class A3, class A4, class A5, class A6, class E=E_F0> // extend AXclass E_F_F0F0F0F0F0F0F0_ :public E { public: // extend typedef R (*func)(const A0 &,const A1 & , const A2 &, const A3 &, const A4 &, const A5 &, const A6 & ) ; // extend AX func f; Expression a0,a1,a2,a3,a4,a5,a6; // extend aX E_F_F0F0F0F0F0F0F0_(func ff, // extend F0 Expression aa0, Expression aa1, Expression aa2, Expression aa3, Expression aa4, Expression aa5, Expression aa6) // extend : f(ff), a0(aa0), a1(aa1), a2(aa2), a3(aa3), a4(aa4), a5(aa5), a6(aa6) {} // extend aX AnyType operator()(Stack s) const {return SetAny<R>( f( GetAny<A0>((*a0)(s)), GetAny<A1>((*a1)(s)), GetAny<A2>((*a2)(s)), GetAny<A3>((*a3)(s)), GetAny<A4>((*a4)(s)), GetAny<A5>((*a5)(s)), GetAny<A6>((*a6)(s)) ) );} // extend aX virtual size_t nbitem() const {return a6->nbitem(); } // modif bool MeshIndependent() const {return a0->MeshIndependent() && a1->MeshIndependent()&& a2->MeshIndependent() && a3->MeshIndependent()&& a4->MeshIndependent()&& a5->MeshIndependent()&& a6->MeshIndependent();} // extend aX};template<class R,class A=R,class B=A,class C=B, class D=C ,class E=D ,class F=E ,class G=F ,class CODE=E_F_F0F0F0F0F0F0F0_<R,A,B,C,D,E,F,G,E_F0> > // extend class OneOperator7_ : public OneOperator { // 3->4 aType r; // return type typedef typename CODE::func func; func f;public: E_F0 * code(const basicAC_F0 & args) const { return new CODE(f, t[0]->CastTo(args[0]), t[1]->CastTo(args[1]), t[2]->CastTo(args[2]), t[3]->CastTo(args[3]), t[4]->CastTo(args[4]), t[5]->CastTo(args[5]), t[6]->CastTo(args[6]));} // extend OneOperator7_(func ff): // 3->4 OneOperator(map_type[typeid(R).name()], map_type[typeid(A).name()],
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -