fork download
  1. #include <iostream>
  2.  
  3. void noexcept_dummy() noexcept;
  4. typedef decltype(noexcept_dummy)* f_ptr_t;
  5.  
  6. void f() noexcept { std::cout << "f called\n"; }
  7. void g() noexcept(false) { std::cout << "g called\n"; }
  8.  
  9. void test(f_ptr_t func) { func(); }
  10.  
  11. int main() {
  12. f_ptr_t x = &f;
  13. //f_ptr_t x = &g; // error
  14. std::cout << std::boolalpha
  15. << "f: " << noexcept(f()) << "\n"
  16. << "g: " << noexcept(g()) << "\n"
  17. << "x: " << noexcept(x()) << "\n";
  18. test(x);
  19. return 0;
  20. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
f: true
g: false
x: true
f called