Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not familiar with C++11's noexcept specifier, but the throw() example from [1] shows how throwing a W object is caught at run-time instead of compile-time. I think compile-time exception checking is infeasible because C++ functions without a throw() specifier might throw any exception, so the caller can't actually check at compile-time what exceptions might be thrown.

  void f() throw(X, Y) 
  {
      int n = 0;
      if (n) throw X(); // OK
      if (n) throw Z(); // also OK
      throw W(); // will call std::unexpected() at run-time, not a compile-time error
  }
[1] http://en.cppreference.com/w/cpp/language/except_spec


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: