COIN-OR::LEMON - Graph Library

Changeset 1203:14f951664a63 in lemon-0.x


Ignore:
Timestamp:
03/07/05 08:57:06 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1615
Message:

Nothing special

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/alpar/named-param-test4.cc

    r1105 r1203  
     1///\file
     2///Named template study
     3
     4///\e
     5
     6///\e
     7///
    18class AlgorithmDefaultTypes
    29{
    310public:
     11///\e
     12
     13///\e
     14///
    415  typedef int Adat;
    516};
    617
     18///\e
     19
     20///\e
     21///
    722template<class T = AlgorithmDefaultTypes>
    823class AlgorithmTypes : public T
    924{
    1025public:
     26///\e
     27
     28///\e
     29///
    1130  template<class X>
    1231  class SetAdat : public T { X Adat; };
    1332};
    1433
     34///\e
     35
     36///\e
     37///
    1538template<class T = AlgorithmTypes<> >
    1639class AlgorithmDefaultDataFields : public T
    1740{
    1841protected:
     42///\e
     43
     44///\e
     45///
     46  typedef T TypeTraits; //Jo ez a nev?
     47protected:
     48///\e
     49
     50///\e
     51///
    1952  typename T::Adat adat;
    2053};
    2154
     55///\e
     56
     57///\e
     58///
    2259template<class T = AlgorithmDefaultDataFields<> >
    2360class Algorithm : public T
     
    3269    X adat;
    3370    public:
     71    typedef X Adat;
    3472    _SetAdat() {}; //"Algorithm<>::_SetAdat<double> b;"-hez kell!!!!
    3573                   // De az is rossz!!!!!
     
    3775  };
    3876 
     77 ///\name Funtion Named Parameters
     78 
     79  ///@{
     80
     81  ///\e
     82 
     83  ///\e
     84  ///
    3985  template<class X>
    4086  Algorithm<_SetAdat<X> > setAdat(const X &x) {
    4187    return Algorithm<_SetAdat<X> >(_SetAdat<X>(*this,x));
    4288  }
     89
     90  ///@}
     91  ///\name Named Parameters
    4392 
     93  ///@{
     94
     95  ///\e
     96 
     97  ///\e
     98  ///
     99  template<class X>
     100  class SetAdat :
     101    public Algorithm<AlgorithmDefaultDataFields<
     102    typename T::TypeTraits::template SetAdat<X> > >
     103  {};
     104 
     105  ///@} 
     106
     107///\e
     108
     109///\e
     110///
    44111  Algorithm &setIntAdat(int i) {_intAdat=i;return *this;}
    45112  //vagy:
     113///Vagy
     114
     115///Vagy...
     116///
    46117  Algorithm &intAdat(int i) {_intAdat=i;return *this;}
    47118 
     119  //Maga az algoritmus!!!!!!!
     120///\e
     121
     122///\e
     123///
    48124  typename T::Adat run()
    49125  {
    50126    //Itt csinalunk valamit
    51     return typename T::Adat();   
     127    return adat;   
    52128  }
     129
    53130  ~Algorithm()
    54131  {
     
    57134};
    58135
     136///\e
     137
     138///\e
     139///
    59140Algorithm<> algorithm()
    60141{
     
    65146{
    66147  Algorithm<> a;
     148  a.run();
    67149
    68   Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!!
     150//   Algorithm<>::_SetAdat<double> b; b=b;//Ez itt nem az, amit szeretnenk!!!
     151//   //  b.run();
     152 
     153  Algorithm<>::SetAdat<double> c; //Algorithm<>::Adat<double> c; jobb vo'na
     154  c.run();
    69155
    70   Algorithm<>::SetAdat<double> c; c=c; //Ez itt nem az, amit szeretnenk!!!
    71 
    72   a.run();
    73   //  b.run();
    74   //  c.run();
    75  
    76156  algorithm().run();
    77157  algorithm().setAdat(5.2).run();
Note: See TracChangeset for help on using the changeset viewer.