fork download
  1. #include <limits>
  2.  
  3. template<bool Condition, typename T>
  4. struct EnableIf;
  5. template<typename T>
  6. struct EnableIf<true, T>
  7. {
  8. typedef T Type;
  9. };
  10.  
  11. struct Foo
  12. {
  13. enum
  14. {
  15. Sum = 1
  16. };
  17. typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
  18. };
  19.  
  20. int main() {}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:66: error: ‘std::numeric_limits<long unsigned int>::max()’ cannot appear in a constant-expression
     typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
                                                                  ^
prog.cpp:17:70: error: a function call cannot appear in a constant-expression
     typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
                                                                      ^
prog.cpp:17:97: error: template argument 1 is invalid
     typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
                                                                                                 ^
prog.cpp:17:100: error: expected ‘;’ at end of member declaration
     typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
                                                                                                    ^
prog.cpp:17:105: error: ‘ProbabilityType’ does not name a type
     typedef EnableIf< (::std::numeric_limits<unsigned long int>::max() > Sum), unsigned long int>::Type ProbabilityType;
                                                                                                         ^
stdout
Standard output is empty