src/work/deba/test.cpp
changeset 1345 71e0777b65e0
parent 1210 f02396423239
equal deleted inserted replaced
1:6d5a6e22d805 2:d3f8f1a4a225
     2 
     2 
     3 using namespace std;
     3 using namespace std;
     4 
     4 
     5 #include <lemon/utility.h>
     5 #include <lemon/utility.h>
     6 
     6 
     7 using namespace std;
     7 using namespace lemon;
     8 /*
     8 /*
     9 struct _EmptyList {
     9 struct _EmptyList {
    10   void write() const {}
    10   void write() const {}
    11 };
    11 };
    12 
    12 
    55 */
    55 */
    56 
    56 
    57 class A {
    57 class A {
    58 public:
    58 public:
    59   typedef int X;
    59   typedef int X;
       
    60   typedef True XD;
    60 };
    61 };
    61 
    62 
    62 class C {
    63 class C {
    63 };
    64 };
    64 
    65 
    65 template <typename A> 
    66 
    66 class TRUE {
    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> {
    67 public:
    75 public:
    68   static const bool state = true;
    76   static const bool state = true;
    69 };
    77 };
    70 
    78 
    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 
    79 
    83 int main() {
    80 int main() {
    84   printf("%s\n", B<A>::state(), true ? "true" : "false");
    81   printf("%s\n", B<A>::state ? "true" : "false");
    85   printf("%s\n", B<C>::state(), true ? "true" : "false");
    82   printf("%s\n", B<C>::state ? "true" : "false");
    86   return 0;
    83   return 0;
    87 }
    84 }