author | deba |
Fri, 11 Mar 2005 16:44:20 +0000 | |
changeset 1213 | 6cc106135d31 |
parent 1036 | 2f514b5c7122 |
child 1267 | a93f94dbe3d3 |
permissions | -rw-r--r-- |
1 #include <iostream>
3 using namespace std;
5 #include <lemon/utility.h>
7 using namespace std;
8 /*
9 struct _EmptyList {
10 void write() const {}
11 };
13 template <typename _Item, typename _Next>
14 struct _AddNode {
15 typedef _Next Next;
16 typedef _Item Item;
18 const Item item;
19 const Next& next;
21 _AddNode(const Item& _item, const Next& _next)
22 : item(_item), next(_next) {}
24 void write() const {
25 next.write();
26 cout << item << ' ';
27 }
28 };
30 template <typename _List = _EmptyList>
31 struct _Writer {
32 typedef _List List;
34 const List list;
36 _Writer(const List& _list = List()) : list(_list) {}
39 template <typename Item> _Writer<_AddNode<Item, List> > add(Item item) const {
40 return _Writer<_AddNode<Item, List> >(_AddNode<Item, List>(item, list));
41 }
43 void write() const {
44 list.write();
45 cout << endl;
46 }
47 };
50 typedef _Writer<> Writer;
52 int main() {
53 Writer().add(3).add("alpha").add(4.53).write();
54 }
55 */
57 class A {
58 public:
59 typedef int X;
60 };
62 class C {
63 };
65 template <typename A>
66 class TRUE {
67 public:
68 static const bool state = true;
69 };
71 template <typename _A>
72 class B {
73 public:
74 typedef enable_if<A::X, int> state;
75 };
77 template <typename _A>
78 class B<_A, void> {
79 public:
80 static const bool state = true;
81 };
83 int main() {
84 printf("%s\n", B<A>::state(), true ? "true" : "false");
85 printf("%s\n", B<C>::state(), true ? "true" : "false");
86 return 0;
87 }