fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. constexpr int sum(int a, int b) {
  5. return a + b;
  6. }
  7.  
  8. int main() {
  9. static_assert(sum(3,8) == 11, "compile-time evaluation");
  10. //uncomment line below to get an error even though sum only evaluates to true
  11. //static_assert((bool)sum(3,rand()%8), "irrelevant message");
  12.  
  13. std::cout << sum(3,rand()%8) << std::endl;
  14. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
10