| 1 |
// PR c++/89652 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
template <typename T> constexpr auto foo (T &e) { return e.foo (); } |
| 6 |
template <typename T> constexpr auto bar (T &e) { return foo (e); } |
| 7 |
template <typename T, int N> struct A { typedef T a[N]; }; |
| 8 |
template <typename T, unsigned long N> struct B { |
| 9 |
typedef T *b; |
| 10 |
typename A<T, N>::a d; |
| 11 |
constexpr b foo () { return d; } |
| 12 |
}; |
| 13 |
template <typename> struct C { long m; }; |
| 14 |
struct D { long n; }; |
| 15 |
template <typename, unsigned long> struct E { |
| 16 |
B<C<int>, 1>::b p; |
| 17 |
constexpr D operator* () { return {p->m}; } |
| 18 |
constexpr E operator++ (int) { auto a{*this}; ++p; return a; } |
| 19 |
}; |
| 20 |
template <typename T, unsigned long N> |
| 21 |
constexpr bool operator!= (E<T, N> a, E<T, N>) { return a.p; } |
| 22 |
template <unsigned long N, typename T, unsigned long M> |
| 23 |
constexpr auto baz (B<T, M> s, B<D, N>) |
| 24 |
{ |
| 25 |
B<D, M> t{}; |
| 26 |
auto q{foo (t)}; |
| 27 |
using u = E<T, M>; |
| 28 |
auto v = u{bar (s)}; |
| 29 |
auto w = u{}; |
| 30 |
while (v != w) |
| 31 |
*q++ = *v++; |
| 32 |
return t; |
| 33 |
} |
| 34 |
constexpr auto a = B<C<int>, 5>{}; |
| 35 |
auto b = B<D, 0>{}; |
| 36 |
auto c = baz (a, b); |