src/work/deba/test.cpp
author deba
Fri, 11 Mar 2005 16:44:20 +0000
changeset 1213 6cc106135d31
parent 1036 2f514b5c7122
child 1267 a93f94dbe3d3
permissions -rw-r--r--
Solve conflict.
     1 #include <iostream>
     2 
     3 using namespace std;
     4 
     5 #include <lemon/utility.h>
     6 
     7 using namespace std;
     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 };
    61 
    62 class C {
    63 };
    64 
    65 template <typename A> 
    66 class TRUE {
    67 public:
    68   static const bool state = true;
    69 };
    70 
    71 template <typename _A> 
    72 class B {
    73 public:
    74   typedef enable_if<A::X, int> state;
    75 };
    76 
    77 template <typename _A>
    78 class B<_A, void> {
    79 public:
    80   static const bool state = true;
    81 };
    82 
    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 }