# HG changeset patch # User alpar # Date 1106925574 0 # Node ID 6777f0b0e7b59260ca815f788d0906f2d0f8cb9f # Parent 23a54f88927263f550c5c94a53d909475615c907 One more trial/approach for named params (Under constr.) diff -r 23a54f889272 -r 6777f0b0e7b5 src/work/alpar/named-param-test4.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/alpar/named-param-test4.cc Fri Jan 28 15:19:34 2005 +0000 @@ -0,0 +1,78 @@ +class AlgorithmDefaultTypes +{ +public: + typedef int Adat; +}; + +template +class AlgorithmTypes : public T +{ +public: + template + class SetAdat : public T { X Adat; }; +}; + +template > +class AlgorithmDefaultDataFields : public T +{ +protected: + typename T::Adat adat; +}; + +template > +class Algorithm : public T +{ + int _intAdat; +public: + Algorithm() {}; + Algorithm(const T &tt) : T(tt) {}; + + template class _SetAdat : public T { + protected: + X adat; + public: + _SetAdat() {}; //"Algorithm<>::_SetAdat b;"-hez kell!!!! + // De az is rossz!!!!! + _SetAdat(const T &t,const X& x) : T(t), adat(x) {}; + }; + + template + Algorithm<_SetAdat > setAdat(const X &x) { + return Algorithm<_SetAdat >(_SetAdat(*this,x)); + } + + Algorithm &setIntAdat(int i) {_intAdat=i;return *this;} + //vagy: + Algorithm &intAdat(int i) {_intAdat=i;return *this;} + + typename T::Adat run() + { + //Itt csinalunk valamit + return typename T::Adat(); + } + ~Algorithm() + { + //Itt nem csinalunk semmit + } +}; + +Algorithm<> algorithm() +{ + return Algorithm<>(); +} + +int main() +{ + Algorithm<> a; + + Algorithm<>::_SetAdat b; b=b;//Ez itt nem az, amit szeretnenk!!! + + Algorithm<>::SetAdat c; c=c; //Ez itt nem az, amit szeretnenk!!! + + a.run(); + // b.run(); + // c.run(); + + algorithm().run(); + algorithm().setAdat(5.2).run(); +}