📄 operator.hpp
字号:
template<class A,class B>struct set_eq_array_sub: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa -= b; return a;}};template<class A,class B>struct set_eq_array_mul: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa *= b; return a;}};template<class A,class B>struct set_eq_array_div: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,b)); A aa(a); aa /= b; return a;}};template<class A,class B>struct set_eq_arrayp: public binary_function<A,B,A> { static A f(A const & a, B const & b) { A aa(a); aa = *b; return a;}};// ---------------------------------------------template<class A,class B>struct set_eq_arraypd: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,*b));A aa(a); aa = *b; delete b; return a;}};template<class A,class B>struct set_eq_arrayp_sub: public binary_function<A,B,A> { static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa -= *b; return a;}};template<class A,class B>struct set_eq_arrayp_mul: public binary_function<A,B,A> { static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa *= *b; return a;}};template<class A,class B>struct set_eq_arrayp_div: public binary_function<A,B,A> { static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa /= *b; return a;}};template<class A,class B>struct set_eq_arrayp_add: public binary_function<A,B,A> { static A f(A const & a, B const & b) { assert(SameShape(a,*b)); A aa(a); aa += *b; return a;}};template<class A,class B>struct set_eq_arraypd_add: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa += *b; delete b; return a;}};template<class A,class B>struct set_eq_arraypd_sub: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa -= *b; delete b; return a;}};template<class A,class B>struct set_eq_arraypd_mul: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa *= *b; delete b; return a;}};template<class A,class B>struct set_eq_arraypd_div: public binary_function<A,B,A> { static A f(A const & a, B const & b) {assert(SameShape(a,*b)); A aa(a); aa /= *b; delete b; return a;}};template<class A>struct PrintP: public binary_function<ostream*,A,ostream*> { static ostream* f(ostream* const & a,const A & b) { *a << *b; //delete b; mars 2006 FH return a;}};template<class A>struct PrintPnd: public binary_function<ostream*,A,ostream*> { static ostream* f(ostream* const & a,const A & b) { *a << *b; return a;}};template<class R,class A> R * set_eqP(R* a,A b){ if (*a != b) delete (*a) ; ( *a =b); return a;}template<class R,class A> R * set_eqdestroy(R* a,A b){ if (*a != b) (**a).destroy() ;// le cas debile Th=Th doit marcher // cout << " set_eqdestroy " << a << " " << b << endl; ( *a =b); return a;} template<class R,class A> R * set_eqdestroy_incr(R* a,A b){ if(b) (*b).increment() ; if(*a) (**a).destroy() ;// le cas debile Th=Th doit marcher // cout << " set_eqdestroy " << a << " " << b << endl; ( *a =b); return a;} template<class R> R * set_copy( R* const & a,const R & b){ SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); memcpy(a,&b,sizeof(R)); return a;}template<class R> R * set_copyp( R* const & a,const R & b){ SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); // memcpy(a,&b,sizeof(R)); *a = b; return a;}template<class R> R ** set_copyp_new( R** a,R* b){ SHOWVERB( cout << " set_copy " << typeid(R).name() << " " << &b << endl); //memcpy(a,&b,sizeof(R)); return a; FH 2007 // cerr << " set_copyp_new " << typeid(R).name() << " " << b << " " << *b ; *a = new R(*b); // cerr << " -> " << *a << endl; return a; }template<class R> R ** set_copy_incr( R** const & a, R * const & b){ *a=b; if(b) b->increment(); return a;}template<class R,class A> R * set_init2( R* const & a,const A & b,const A & c){ SHOWVERB( cout << " set_init2 " << typeid(R).name() << " " << &b << " " << &c << endl); a->init(b,c); return a;}template<class R,class A> R * set_init( R* const & a,const A & b){ SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); a->init(b); return a;}template<class R,class A> R * set_initp( R* const & a,const A & b){ SHOWVERB( cout << " set_init " << typeid(R).name() << " " << &b << endl); a->init(*b); return a;}template<class R,class A=R,class B=A> struct Op2_add0: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (a + b);} }; template<class R,class A=R,class B=A> struct Op2_build: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return R(a,b);} }; template<class R,class A=R,class B=A> struct Op2_pbuild: public binary_function<A,B,R*> { static R *f(const A & a,const B & b) { return new R(a,b);} }; template<class R,class A=R,class B=A> struct Op2_add__n: public binary_function<A,B,R*> { static R * f(const A & a,const B & b) { return new R(a + b);} }; template<class R,class A=R,class B=A> struct Op2_addp_n: public binary_function<A,B,R*> { static R* f(const A & a,const B & b) { return new R(*a + b);} }; template<class R,class A=R,class B=A> struct Op2_add_pn: public binary_function<A,B,R*> { static R* f(const A & a,const B & b) { return new R(a + *b);} }; template<class R,class A=R,class B=A> struct Op2_sub0: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (a - b);} }; template<class R,class A=R> struct Op1_subp: public unary_function<A,R> { static R f(const A & a) { return (- *a );} }; template<class R,class A=R,class B=A> struct Op2_mulcp: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (a * *b);} }; template<class R,class A=R,class B=A> struct Op2_mulc: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (a * b);} }; template<class R,class A=R,class B=A> struct Op2_mulpc: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (b * *a);} }; template<class R,class A=R,class B=A> struct Op2_mulpcp: public binary_function<A,B,R> { static R f(const A & a,const B & b) { return (*a * *b);} }; template<class R,class A=R,class B=A> struct Op2_sub__n: public binary_function<A,B,R*> { static R * f(const A & a,const B & b) { return new R(a - b);} }; template<class R,class A=R,class B=A> struct Op2_subp_n: public binary_function<A,B,R*> { static R* f(const A & a,const B & b) { return new R(*a - b);} }; template<class R,class A=R,class B=A> struct Op2_sub_pn: public binary_function<A,B,R*> { static R* f(const A & a,const B & b) { return new R(a - *b);} }; template<class R,class A=R,class B=A,class C=A> struct Op3_p: public ternary_function<A,B,C,R*> { static R* f(Stack s,const A & a,const B & b,const C & c ) { return new R(a,b,c);} }; template<class R,class A=R,class B=A> struct Op2_p: public binary_function<A,B,R*> { static R* f(const A & a,const B & b) { return new R(a,b);} }; template<class T>class Transpose{ public: T t; Transpose( T v) : t(v) {} template<class TT> Transpose( TT v) : t(v) {} template<class TT> Transpose( TT * v) : t(*v) {} operator const T & () const {return t;}};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -