Skip to content

Instantly share code, notes, and snippets.

@nekko1119
Created July 26, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekko1119/b05acb522f95733af2d6 to your computer and use it in GitHub Desktop.
Save nekko1119/b05acb522f95733af2d6 to your computer and use it in GitHub Desktop.
constexpr int f() { return 0; }
constexpr int g();
static_assert(noexcept(f()), "");
static_assert(!noexcept(g()), "");
constexpr int h(bool b) { return b ? 0 : throw 42; }
static_assert(noexcept(h(true)), "");
static_assert(!noexcept(h(false)), "");
#include <iostream>
int main()
{
std::cout << std::boolalpha;
std::cout << noexcept(h(true));
bool b = true;
std::cout << noexcept(h(b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment