src/work/deba/test.cpp
author alpar
Wed, 16 Mar 2005 07:56:25 +0000
changeset 1218 5331168bbb18
parent 1036 2f514b5c7122
child 1267 a93f94dbe3d3
permissions -rw-r--r--
- Several updates and clarifications on dijkstra.h
- bfs.h and dfs.h is synchronized with dijkstra.h
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@1210
     7
using namespace std;
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@1210
    60
};
deba@1210
    61
deba@1210
    62
class C {
deba@1210
    63
};
deba@1210
    64
deba@1210
    65
template <typename A> 
deba@1210
    66
class TRUE {
deba@1210
    67
public:
deba@1210
    68
  static const bool state = true;
deba@1210
    69
};
deba@1210
    70
deba@1210
    71
template <typename _A> 
deba@1210
    72
class B {
deba@1210
    73
public:
deba@1210
    74
  typedef enable_if<A::X, int> state;
deba@1210
    75
};
deba@1210
    76
deba@1210
    77
template <typename _A>
deba@1210
    78
class B<_A, void> {
deba@1210
    79
public:
deba@1210
    80
  static const bool state = true;
deba@1210
    81
};
deba@1210
    82
deba@1210
    83
int main() {
deba@1210
    84
  printf("%s\n", B<A>::state(), true ? "true" : "false");
deba@1210
    85
  printf("%s\n", B<C>::state(), true ? "true" : "false");
deba@1210
    86
  return 0;
deba@1210
    87
}