fork(1) download
  1. #include <iostream>
  2. #include <typeinfo>
  3. #include <type_traits>
  4.  
  5.  
  6. template <int SZ>
  7. class Internal
  8. {
  9. char arr[SZ];
  10. };
  11.  
  12. template < int SZ>
  13. struct helper
  14. {
  15. typedef typename std::conditional<(SZ > 1000 && SZ <9999),Internal<SZ>,Internal<1> >::type type;
  16. };
  17.  
  18. template < int SZ>
  19. struct A : public helper<SZ>::type
  20. {
  21. typedef typename helper<SZ>::type base;
  22. };
  23.  
  24. int main() {
  25. std::cout << typeid(A<1024>::base).name() << std::endl;
  26. A<1024> x;
  27. std::cout << typeid(A<-34>::base).name() << std::endl;
  28. A<-34> y;
  29. return 0;
  30. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
8InternalILi1024EE
8InternalILi1EE