#if __cplusplus < 201103L
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
#endif
namespace dr2100 { template<const int *P, bool = true> struct X {};
template<typename T> struct A {
static const int n = 1;
int f() {
return X<&n>::n; }
int g() {
static const int n = 2;
return X<&n>::n; #if __cplusplus < 201702L
#endif
}
};
template<const int *P> struct X<P> {
#if __cplusplus < 201103L
static const int n = 0;
#else
static const int n = *P;
#endif
};
int q = A<int>().f() + A<int>().g();
template<int N, bool = true> struct Y {};
template<typename T> struct B {
static const int n = 1;
int f() {
return Y<n>::declared_later; }
int g() {
static const int n = 2;
return Y<n>::declared_later; }
};
template<int N> struct Y<N> {
static const int declared_later = 0;
};
}
namespace dr2103 { void f() {
int a;
int &r = a; struct Inner {
void f() {
int &s = r; (void)s;
}
};
}
}
namespace dr2120 { struct A {};
struct B : A {};
struct C { A a; };
struct D { C c[5]; };
struct E : B { D d; };
static_assert(__is_standard_layout(B), "");
static_assert(__is_standard_layout(D), "");
static_assert(!__is_standard_layout(E), "");
}
namespace dr2126 { #if __cplusplus >= 201103L
struct A { int n; };
const A &a = {1}; A &b = (A &)(const A &)A{1}; A &&c = (A &&)(const A &)A{1};
A &&d = {1}; const A &e = (A &)(A &&) A{1}; A &&f = (A &&)(A &&) A{1};
constexpr const A &g = {1}; constexpr A &&h = {1};
struct B { const A &a; };
B i = {{1}}; const B j = {{1}}; constexpr B k = {{1}};
static_assert(a.n == 1, "");
static_assert(b.n == 1, "");
static_assert(c.n == 1, "");
static_assert(d.n == 1, ""); static_assert(e.n == 1, ""); static_assert(f.n == 1, ""); static_assert(g.n == 1, "");
static_assert(h.n == 1, ""); static_assert(i.a.n == 1, ""); static_assert(j.a.n == 1, ""); static_assert(k.a.n == 1, "");
#endif
}
namespace dr2140 { #if __cplusplus >= 201103L
union U { int a; decltype(nullptr) b; };
constexpr int *test(U u) {
return u.b;
}
static_assert(!test({123}), "u.b should be valid even when b is inactive");
#endif
}
namespace dr2157 { #if __cplusplus >= 201103L
enum E : int;
struct X {
enum dr2157::E : int(); };
#endif
}
namespace dr2170 { #if __cplusplus >= 201103L
void f() {
constexpr int arr[3] = {1, 2, 3}; struct S {
int get(int n) { return arr[n]; }
const int &get_ref(int n) { return arr[n]; } };
}
#endif
}
namespace dr2171 { #if __cplusplus >= 201103L
struct NonConstCopy {
NonConstCopy(NonConstCopy &) = default;
NonConstCopy &operator=(NonConstCopy &) = default;
};
static_assert(__has_trivial_copy(NonConstCopy), "");
static_assert(__is_trivially_constructible(NonConstCopy, NonConstCopy &), "");
static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy), "");
static_assert(!__is_trivially_constructible(NonConstCopy, const NonConstCopy &), "");
static_assert(!__is_trivially_constructible(NonConstCopy, NonConstCopy &&), "");
static_assert(__has_trivial_assign(NonConstCopy), "");
static_assert(__is_trivially_assignable(NonConstCopy &, NonConstCopy &), "");
static_assert(!__is_trivially_assignable(NonConstCopy &, const NonConstCopy &), "");
static_assert(!__is_trivially_assignable(NonConstCopy &, NonConstCopy), "");
static_assert(!__is_trivially_assignable(NonConstCopy &, NonConstCopy &&), "");
static_assert(__is_trivially_assignable(NonConstCopy &&, NonConstCopy &), "");
static_assert(!__is_trivially_assignable(NonConstCopy &&, const NonConstCopy &), "");
static_assert(!__is_trivially_assignable(NonConstCopy &&, NonConstCopy), "");
static_assert(!__is_trivially_assignable(NonConstCopy &&, NonConstCopy &&), "");
#endif
}
namespace dr2180 { class A {
A &operator=(const A &); A &operator=(A &&); };
struct B : virtual A {
B &operator=(const B &);
B &operator=(B &&); virtual void foo() = 0;
};
#if __cplusplus < 201103L
B &B::operator=(const B&) = default; B &B::operator=(B&&) = default; #else
B &B::operator=(const B&) = default; B &B::operator=(B&&) = default; #endif
}