template<bool b> struct ExceptionIf { static int f(); };
template<> struct ExceptionIf<false> { typedef int f; };
namespace InClassInitializers {
bool ThrowSomething() noexcept(false);
struct ConstExpr { bool b = noexcept(ConstExpr()) && ThrowSomething(); };
struct TemplateArg { int n = ExceptionIf<noexcept(TemplateArg())>::f(); };
struct Nested {
struct Inner { int n = ExceptionIf<noexcept(Nested())>::f(); } inner; };
struct Nested2 {
struct Inner;
int n = Inner().n; struct Inner { int n = ExceptionIf<noexcept(Nested2())>::f(); } inner;
};
}
namespace ExceptionSpecification {
struct Nested {
struct T {
T() noexcept(!noexcept(Nested())); } t; };
}
namespace DefaultArgument {
struct Default {
struct T {
T(int = ExceptionIf<noexcept(Default())>::f());
} t;
};
}
namespace ImplicitDtorExceptionSpec {
struct A {
virtual ~A();
struct Inner {
~Inner() throw();
};
Inner inner;
};
struct B {
virtual ~B() {} };
struct C : B {
virtual ~C() {}
A a;
};
struct D : B {
~D(); struct E {
~E();
struct F {
~F() throw(A);
} f;
} e;
};
}
struct nothrow_t {} nothrow;
void *operator new(decltype(sizeof(0)), nothrow_t) noexcept;
namespace PotentiallyConstructed {
template<bool NE> struct A {
A() noexcept(NE);
A(const A&) noexcept(NE);
A(A&&) noexcept(NE);
A &operator=(const A&) noexcept(NE);
A &operator=(A&&) noexcept(NE);
~A() noexcept(NE);
};
template<bool NE> struct B : virtual A<NE> {};
template<bool NE> struct C : virtual A<NE> {
virtual void f() = 0; };
template<bool NE> struct D final : C<NE> {
void f();
};
template<typename T, bool A, bool B, bool C, bool D, bool E, bool F> void check() {
T *p = nullptr;
T &a = *p;
static_assert(noexcept(a = a) == D, "");
static_assert(noexcept(a = static_cast<T&&>(a)) == E, "");
static_assert(noexcept(delete &a) == F, "");
static_assert(noexcept(new (nothrow) T()) == A, ""); static_assert(noexcept(new (nothrow) T(a)) == B, "");
static_assert(noexcept(new (nothrow) T(static_cast<T&&>(a))) == C, "");
}
template void check<A<false>, 0, 0, 0, 0, 0, 0>();
template void check<A<true >, 1, 1, 1, 1, 1, 1>();
template void check<B<false>, 0, 0, 0, 0, 0, 0>();
template void check<B<true >, 1, 1, 1, 1, 1, 1>();
template void check<C<false>, 1, 1, 1, 0, 0, 0>(); template void check<C<true >, 1, 1, 1, 1, 1, 1>(); template void check<D<false>, 0, 0, 0, 0, 0, 0>();
template void check<D<true >, 1, 1, 1, 1, 1, 1>();
struct Cfalse : virtual A<false> {
virtual void f() = 0;
Cfalse() noexcept;
Cfalse(const Cfalse&) noexcept;
Cfalse(Cfalse&&) noexcept;
};
Cfalse::Cfalse() noexcept = default;
Cfalse::Cfalse(const Cfalse&) noexcept = default;
Cfalse::Cfalse(Cfalse&&) noexcept = default;
}