| Line |  | 
|---|
| 1 | #include <iostream> | 
|---|
| 2 |  | 
|---|
| 3 | using namespace std; | 
|---|
| 4 |  | 
|---|
| 5 | #include <lemon/utility.h> | 
|---|
| 6 |  | 
|---|
| 7 | using namespace lemon; | 
|---|
| 8 | /* | 
|---|
| 9 | struct _EmptyList { | 
|---|
| 10 | void write() const {} | 
|---|
| 11 | }; | 
|---|
| 12 |  | 
|---|
| 13 | template <typename _Item, typename _Next> | 
|---|
| 14 | struct _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 |  | 
|---|
| 30 | template <typename _List = _EmptyList> | 
|---|
| 31 | struct _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 |  | 
|---|
| 50 | typedef _Writer<> Writer; | 
|---|
| 51 |  | 
|---|
| 52 | int main() { | 
|---|
| 53 | Writer().add(3).add("alpha").add(4.53).write(); | 
|---|
| 54 | } | 
|---|
| 55 | */ | 
|---|
| 56 |  | 
|---|
| 57 | class A { | 
|---|
| 58 | public: | 
|---|
| 59 | typedef int X; | 
|---|
| 60 | typedef True XD; | 
|---|
| 61 | }; | 
|---|
| 62 |  | 
|---|
| 63 | class C { | 
|---|
| 64 | }; | 
|---|
| 65 |  | 
|---|
| 66 |  | 
|---|
| 67 | template <typename _A, bool _B = false> | 
|---|
| 68 | class B { | 
|---|
| 69 | public: | 
|---|
| 70 | static const bool state = false; | 
|---|
| 71 | }; | 
|---|
| 72 |  | 
|---|
| 73 | template <typename _A> | 
|---|
| 74 | class B<_A, typename enable_if<typename _A::XD, void>::type> { | 
|---|
| 75 | public: | 
|---|
| 76 | static const bool state = true; | 
|---|
| 77 | }; | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | int 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.