[Lemon-commits] [lemon_svn] alpar: r1504 - hugo/trunk/src/work/alpar

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:45:55 CET 2006


Author: alpar
Date: Fri Jan 28 16:19:34 2005
New Revision: 1504

Added:
   hugo/trunk/src/work/alpar/named-param-test4.cc

Log:
One more trial/approach for named params (Under constr.)


Added: hugo/trunk/src/work/alpar/named-param-test4.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/alpar/named-param-test4.cc	Fri Jan 28 16:19:34 2005
@@ -0,0 +1,78 @@
+class AlgorithmDefaultTypes 
+{
+public:
+  typedef int Adat;
+};
+
+template<class T = AlgorithmDefaultTypes>
+class AlgorithmTypes : public T 
+{
+public:
+  template<class X>
+  class SetAdat : public T { X Adat; };
+};
+
+template<class T = AlgorithmTypes<> >
+class AlgorithmDefaultDataFields : public T
+{
+protected:
+  typename T::Adat adat;
+};
+
+template<class T = AlgorithmDefaultDataFields<> >
+class Algorithm : public T
+{
+  int _intAdat;
+public:
+  Algorithm() {};
+  Algorithm(const T &tt) : T(tt) {};
+
+  template<class X> class _SetAdat : public T {
+    protected:
+    X adat;
+    public:
+    _SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!!
+                   // De az is rossz!!!!!
+    _SetAdat(const T &t,const X& x) : T(t), adat(x) {};
+  };
+  
+  template<class X>
+  Algorithm<_SetAdat<X> > setAdat(const X &x) {
+    return Algorithm<_SetAdat<X> >(_SetAdat<X>(*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<double> b; b=b;//Ez itt nem az, amit szeretnenk!!! 
+
+  Algorithm<>::SetAdat<double> c; c=c; //Ez itt nem az, amit szeretnenk!!!
+
+  a.run();
+  //  b.run();
+  //  c.run();
+  
+  algorithm().run();
+  algorithm().setAdat(5.2).run();
+}



More information about the Lemon-commits mailing list