JoshDreamland icon

Template test cases

JoshDreamland | PRO | 07/09/13 02:04:34 AM UTC | 0 ⭐ | 237 👁️ | Never ⏰ | []
C++ |

890 B

|

None

|

0 👍

/

0 👎

 
template<int x> struct factorial {
  enum r {
    value = x * factorial<x - 1>::value
  };
};
 
template<> struct factorial<1> {
  enum r {
    value = 1
  };
};
 
class seventwenty: factorial<6> {
};
 
template<bool e, class t, class f> class ternary {
  typedef void tp;
};
 
template<class t, class f> class ternary<true, t, f> {
  typedef t tp;
};
 
template<class t, class f> class ternary<false, t, f> {
  typedef f tp;
};
 
 
template<typename o, typename p, typename q> struct matches {
  enum { value = 1 };
};
 
template<typename qq, typename pp> struct matches<pp, qq, qq> {
  enum { value = 2 };
};
 
template<typename pp, typename qq> struct matches<pp, pp, qq> {
  enum { value = 2 };
};
 
template<typename pp, typename qq> struct matches<pp, qq, pp> {
  enum { value = 2 };
};
 
template<typename pp> struct matches<pp, pp, pp> {
  enum { value = 3 };
};

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎