# HG changeset patch # User alpar # Date 1110182226 0 # Node ID 14f951664a63379fa375a2ddab9d1f2d17e38f4c # Parent da44ee225dadbf6bdc570947063da0d090cd5eda Nothing special diff -r da44ee225dad -r 14f951664a63 src/work/alpar/named-param-test4.cc --- a/src/work/alpar/named-param-test4.cc Mon Mar 07 07:53:20 2005 +0000 +++ b/src/work/alpar/named-param-test4.cc Mon Mar 07 07:57:06 2005 +0000 @@ -1,24 +1,61 @@ +///\file +///Named template study + +///\e + +///\e +/// class AlgorithmDefaultTypes { public: +///\e + +///\e +/// typedef int Adat; }; +///\e + +///\e +/// template class AlgorithmTypes : public T { public: +///\e + +///\e +/// template class SetAdat : public T { X Adat; }; }; +///\e + +///\e +/// template > class AlgorithmDefaultDataFields : public T { protected: +///\e + +///\e +/// + typedef T TypeTraits; //Jo ez a nev? +protected: +///\e + +///\e +/// typename T::Adat adat; }; +///\e + +///\e +/// template > class Algorithm : public T { @@ -31,31 +68,75 @@ protected: X adat; public: + typedef X Adat; _SetAdat() {}; //"Algorithm<>::_SetAdat b;"-hez kell!!!! // De az is rossz!!!!! _SetAdat(const T &t,const X& x) : T(t), adat(x) {}; }; + ///\name Funtion Named Parameters + + ///@{ + + ///\e + + ///\e + /// template Algorithm<_SetAdat > setAdat(const X &x) { return Algorithm<_SetAdat >(_SetAdat(*this,x)); } + + ///@} + ///\name Named Parameters + ///@{ + + ///\e + + ///\e + /// + template + class SetAdat : + public Algorithm > > + {}; + + ///@} + +///\e + +///\e +/// Algorithm &setIntAdat(int i) {_intAdat=i;return *this;} //vagy: +///Vagy + +///Vagy... +/// Algorithm &intAdat(int i) {_intAdat=i;return *this;} + //Maga az algoritmus!!!!!!! +///\e + +///\e +/// typename T::Adat run() { //Itt csinalunk valamit - return typename T::Adat(); + return adat; } + ~Algorithm() { //Itt nem csinalunk semmit } }; +///\e + +///\e +/// Algorithm<> algorithm() { return Algorithm<>(); @@ -64,15 +145,14 @@ int main() { Algorithm<> a; + a.run(); - Algorithm<>::_SetAdat b; b=b;//Ez itt nem az, amit szeretnenk!!! +// Algorithm<>::_SetAdat b; b=b;//Ez itt nem az, amit szeretnenk!!! +// // b.run(); + + Algorithm<>::SetAdat c; //Algorithm<>::Adat c; jobb vo'na + c.run(); - Algorithm<>::SetAdat c; c=c; //Ez itt nem az, amit szeretnenk!!! - - a.run(); - // b.run(); - // c.run(); - algorithm().run(); algorithm().setAdat(5.2).run(); }