namespace StdExample {
constexpr int f(void *) { return 0; }
constexpr int f(...) { return 1; }
constexpr int g1() { return f(0); }
constexpr int g2(int n) { return f(n); }
constexpr int g3(int n) { return f(n*0); }
namespace N {
constexpr int c = 5;
constexpr int h() { return c; }
}
constexpr int c = 0;
constexpr int g4() { return N::h(); }
static_assert(f(0) == 0, "");
static_assert(f('0') == 1, "");
static_assert(g1() == 0, "");
static_assert(g2(0) == 1, "");
static_assert(g2(1) == 1, "");
static_assert(g3(0) == 1, "");
static_assert(g3(1) == 1, "");
static_assert(N::h() == 5, "");
static_assert(g4() == 5, "");
constexpr int f(bool b)
{ return b ? throw 0 : 0; } constexpr int f() { return throw 0, 0; }
struct B {
constexpr B(int x) : i(0) { }
int i;
};
int global;
struct D : B {
constexpr D() : B(global) { } };
}
namespace PotentialConstant {
constexpr int Comma(int n) { return (void)(n * 2),
throw 0, 0;
}
int ng; constexpr int BinaryOp1(int n) { return n + ng; } constexpr int BinaryOp2(int n) { return ng + n; }
double dg; constexpr double BinaryOp1(double d) { return d + dg; } constexpr double BinaryOp2(double d) { return dg + d; }
constexpr int Add(int a, int b, int c) { return a + b + c; }
constexpr int FunctionArgs(int a) { return Add(a, ng, a); }
struct S { int a; int b; int c[2]; };
constexpr S InitList(int a) { return { a, ng }; }; constexpr S InitList1a(int a) { return S{ a, ng }; }; constexpr S InitList2(int a) { return { a, a, { ng } }; }; constexpr S InitList3(int a) { return a ? S{ a, a } : S{ a, ng }; };
constexpr int LogicalAnd1(int n) { return n && (throw, 0); } constexpr int LogicalAnd2(int n) { return 1 && (throw, 0); }
constexpr int LogicalOr1(int n) { return n || (throw, 0); } constexpr int LogicalOr2(int n) { return 0 || (throw, 0); }
constexpr int Conditional1(bool b, int n) { return b ? n : ng; } constexpr int Conditional2(bool b, int n) { return b ? n * ng : n + ng; }
constexpr bool BcpCall(int n) {
return __builtin_constant_p((int*)n != &n) ? (int*)n != &n : (int*)n != &n; }
static_assert(BcpCall(0), "");
template<typename T> constexpr T cmin(T a, T b) {
return a < b ? a : b;
}
int n = cmin(3, 5);
struct X {
constexpr X() {}
bool operator<(X); };
X x = cmin(X(), X());
template<typename T>
struct Y {
constexpr Y() {}
constexpr int get() { return T(); }
#if __cplusplus < 201402L
#endif
};
struct Z { operator int(); };
int y1 = Y<int>().get(); int y2 = Y<Z>().get();
}
#ifndef NO_INVALID_CONSTEXPR
namespace PR14550 {
# 126 "p5.cpp" 1 3
int n;
struct A {
static constexpr int f() { return n; }
};
template<typename T> struct B {
B() { g(T::f()); } };
# 134 "p5.cpp" 2
template class B<A>; }
#endif
#if __cplusplus >= 201402L
constexpr void f() { throw; } #endif