COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/deba/test.cpp @ 1314:9269c76551cf

Last change on this file since 1314:9269c76551cf was 1267:a93f94dbe3d3, checked in by Balazs Dezso, 19 years ago

First version of iterable maps.

File size: 1.3 KB
Line 
1#include <iostream>
2
3using namespace std;
4
5#include <lemon/utility.h>
6
7using namespace lemon;
8/*
9struct _EmptyList {
10  void write() const {}
11};
12
13template <typename _Item, typename _Next>
14struct _AddNode {
15  typedef _Next Next;
16  typedef _Item Item;
17 
18  const Item item;
19  const Next& next;
20 
21  _AddNode(const Item& _item, const Next& _next)
22    : item(_item), next(_next) {}
23
24  void write() const {
25    next.write();
26    cout << item << ' ';
27  }
28};
29
30template <typename _List = _EmptyList>
31struct _Writer {
32  typedef _List List;
33
34  const List list;
35
36  _Writer(const List& _list = List()) : list(_list) {}
37
38 
39  template <typename Item> _Writer<_AddNode<Item, List> > add(Item item) const {
40    return _Writer<_AddNode<Item, List> >(_AddNode<Item, List>(item, list));
41  }
42
43  void write() const {
44    list.write();
45    cout << endl;
46  }
47};
48
49
50typedef _Writer<> Writer;
51
52int main() {
53  Writer().add(3).add("alpha").add(4.53).write();
54}
55*/
56
57class A {
58public:
59  typedef int X;
60  typedef True XD;
61};
62
63class C {
64};
65
66
67template <typename _A, bool _B = false>
68class B {
69public:
70  static const bool state = false;
71};
72
73template <typename _A>
74class B<_A, typename enable_if<typename _A::XD, void>::type> {
75public:
76  static const bool state = true;
77};
78
79
80int main() {
81  printf("%s\n", B<A>::state ? "true" : "false");
82  printf("%s\n", B<C>::state ? "true" : "false");
83  return 0;
84}
Note: See TracBrowser for help on using the repository browser.