template<typename T> void f1(T*) throw(T); struct Incomplete;
void test_f1(Incomplete *incomplete_p, int *int_p) {
f1(int_p);
f1(incomplete_p); }
template<typename T> struct A {
template<typename U> struct B {
static void f() noexcept(A<U>().n);
};
constexpr A() : n(true) {}
bool n;
};
static_assert(noexcept(A<int>::B<char>::f()), "");
template<unsigned N> struct S {
static void recurse() noexcept(noexcept(S<N+1>::recurse())); };
template<> struct S<10> {};
void (*pFn2)() noexcept = &S<0>::recurse;
namespace dr1330_example {
template <class T> struct A {
void f(...) throw (typename T::X);
void f(int);
};
int main() {
A<int>().f(42);
}
struct S {
template<typename T> static void f() throw(typename T::X);
typedef decltype(f<S>()) X; };
struct T {
template<typename T> static void f() throw(T**);
typedef decltype(f<S>()) X; };
template<typename T>
struct U {
void f() noexcept(T::error);
void (g)() noexcept(T::error);
};
U<int> uint; }
namespace core_19754_example {
template<typename T> T declval() noexcept;
template<typename T, typename = decltype(T(declval<T&&>()))>
struct is_movable { static const bool value = true; };
template<typename T>
struct wrap {
T val;
void irrelevant(wrap &p) noexcept(is_movable<T>::value);
};
template<typename T>
struct base {
base() {}
base(const typename T::type1 &);
base(const typename T::type2 &);
};
template<typename T>
struct type1 {
wrap<typename T::base> base;
};
template<typename T>
struct type2 {
wrap<typename T::base> base;
};
struct types {
typedef base<types> base;
typedef type1<types> type1;
typedef type2<types> type2;
};
base<types> val = base<types>();
}
namespace pr9485 {
template <typename T> void f1(T) throw(typename T::exception); template <typename T> void f1(T, int = 0) throw(typename T::noitpecxe);
template <typename T> void f2(T) noexcept(T::throws); template <typename T> void f2(T, int = 0) noexcept(T::sworht);
void test() {
f1(0); f2(0); }
}
struct Exc1 { char c[4]; };
struct Exc2 { double x, y, z; };
struct Base {
virtual void f() noexcept; };
template<typename T> struct Derived : Base {
void f() noexcept (sizeof(T) == 4); void g() noexcept (T::error);
};
Derived<Exc1> d1; Derived<Exc2> d2;
namespace PR12763 {
template<bool *B> struct T {
virtual void f() noexcept (*B); };
bool b; struct X : public T<&b> {
virtual void g();
};
void X::g() {} }
namespace Variadic {
template<bool B> void check() { static_assert(B, ""); }
template<bool B, bool B2, bool ...Bs> void check() { static_assert(B, ""); check<B2, Bs...>(); }
template<typename ...T> void consume(T...);
template<typename ...T> void f(void (*...p)() throw (T)) {
void (*q[])() = { p... };
consume((p(),0)...);
}
template<bool ...B> void g(void (*...p)() noexcept (B)) {
consume((p(),0)...);
check<noexcept(p()) == B ...>();
}
template<typename ...T> void i() {
consume([]() throw(T) {} ...);
consume([]() noexcept(sizeof(T) == 4) {} ...);
}
template<bool ...B> void j() {
consume([](void (*p)() noexcept(B)) {
void (*q)() noexcept = p; } ...);
}
void z() {
f<int, char, double>(nullptr, nullptr, nullptr);
g<true, false, true>(nullptr, nullptr, nullptr);
i<int, long, short>();
j<true, true>();
j<true, false>(); }
}
namespace NondefDecls {
template<typename T> void f1() {
int g1(int) noexcept(T::error); }
template void f1<int>(); }