instantiate-self.cpp [plain text]
namespace test1 {
template<typename T> struct A {
struct B { B b; };
B b; };
A<int> a; }
namespace test2 {
template<typename T> struct A {
struct B {
struct C {};
char c[1 + C()]; friend constexpr int operator+(int, C) { return 4; }
};
B b; };
A<int> a; }
namespace test3 {
template<typename T> struct A {
struct B {
enum { Val = 1 };
char c[1 + Val]; };
B b;
};
A<int> a;
}
namespace test4 {
template<typename T> struct M { typedef int type; };
template<typename T> struct A {
struct B { int k[typename A<typename M<T>::type>::B().k[0] + 1]; };
B b; };
A<int> a; }
#if 0
namespace test5 {
template<typename T> struct A {
constexpr T f(T k) { return g(k); }
constexpr T g(T k) {
return k ? f(k-1)+1 : 0;
}
};
constexpr int x = A<int>().f(5);
}
namespace test6 {
template<typename T> constexpr T f(T);
template<typename T> constexpr T g(T t) {
typedef int arr[f(T())];
return t;
}
template<typename T> constexpr T f(T t) {
typedef int arr[g(T())];
return t;
}
int n = f(0);
}
namespace test7 {
template<typename T> constexpr T g(T t) {
return t;
}
template<typename T> constexpr T f(T t) {
typedef int arr[g(T())];
return t;
}
int n = f(0);
}
#endif