src/work/deba/test.cpp
author alpar
Tue, 12 Apr 2005 14:24:57 +0000
changeset 1341 bda966891ea0
parent 1210 f02396423239
permissions -rw-r--r--
GraphReader is made silent
deba@1036
     1
#include <iostream>
deba@1036
     2
deba@1036
     3
using namespace std;
deba@1036
     4
deba@1210
     5
#include <lemon/utility.h>
deba@1036
     6
deba@1267
     7
using namespace lemon;
deba@1210
     8
/*
deba@1036
     9
struct _EmptyList {
deba@1036
    10
  void write() const {}
deba@1036
    11
};
deba@1036
    12
deba@1036
    13
template <typename _Item, typename _Next>
deba@1036
    14
struct _AddNode {
deba@1036
    15
  typedef _Next Next;
deba@1036
    16
  typedef _Item Item;
deba@1036
    17
  
deba@1036
    18
  const Item item;
deba@1036
    19
  const Next& next;
deba@1036
    20
  
deba@1036
    21
  _AddNode(const Item& _item, const Next& _next) 
deba@1036
    22
    : item(_item), next(_next) {}
deba@1036
    23
deba@1036
    24
  void write() const {
deba@1036
    25
    next.write();
deba@1036
    26
    cout << item << ' ';
deba@1036
    27
  }
deba@1036
    28
};
deba@1036
    29
deba@1036
    30
template <typename _List = _EmptyList>
deba@1036
    31
struct _Writer {
deba@1036
    32
  typedef _List List;
deba@1036
    33
deba@1036
    34
  const List list;
deba@1036
    35
deba@1036
    36
  _Writer(const List& _list = List()) : list(_list) {}
deba@1036
    37
deba@1036
    38
  
deba@1036
    39
  template <typename Item> _Writer<_AddNode<Item, List> > add(Item item) const {
deba@1036
    40
    return _Writer<_AddNode<Item, List> >(_AddNode<Item, List>(item, list));
deba@1036
    41
  }
deba@1036
    42
deba@1036
    43
  void write() const {
deba@1036
    44
    list.write();
deba@1036
    45
    cout << endl;
deba@1036
    46
  }
deba@1036
    47
};
deba@1036
    48
deba@1036
    49
deba@1036
    50
typedef _Writer<> Writer;
deba@1036
    51
deba@1036
    52
int main() {
deba@1036
    53
  Writer().add(3).add("alpha").add(4.53).write();
deba@1036
    54
}
deba@1210
    55
*/
deba@1210
    56
deba@1210
    57
class A {
deba@1210
    58
public:
deba@1210
    59
  typedef int X;
deba@1267
    60
  typedef True XD;
deba@1210
    61
};
deba@1210
    62
deba@1210
    63
class C {
deba@1210
    64
};
deba@1210
    65
deba@1267
    66
deba@1267
    67
template <typename _A, bool _B = false> 
deba@1267
    68
class B {
deba@1267
    69
public:
deba@1267
    70
  static const bool state = false;
deba@1267
    71
};
deba@1267
    72
deba@1267
    73
template <typename _A> 
deba@1267
    74
class B<_A, typename enable_if<typename _A::XD, void>::type> {
deba@1210
    75
public:
deba@1210
    76
  static const bool state = true;
deba@1210
    77
};
deba@1210
    78
deba@1210
    79
deba@1210
    80
int main() {
deba@1267
    81
  printf("%s\n", B<A>::state ? "true" : "false");
deba@1267
    82
  printf("%s\n", B<C>::state ? "true" : "false");
deba@1210
    83
  return 0;
deba@1210
    84
}