1// Origin c++/45558
2// { dg-do compile }
3
4template <typename S, typename T>
5struct C
6{
7  template <typename U>
8  struct B
9  {
10    template <typename W>
11    struct E
12    {
13      explicit E(const W &x) : w(x) {}
14      const W &w;
15    };
16  };
17};
18
19struct F;
20template <typename X>
21struct D
22{
23  D() {}
24};
25
26const D<F> g;
27template <typename S, typename T>
28struct A
29{
30  template <typename U>
31  struct B : C<S, T>::template B<U>
32  {
33    typedef typename C<S, T>::template B<U> V;
34    static const D<typename V::template E<D<F> > > a;
35  };
36};
37
38template <typename S, typename T>
39template <typename U>
40const D<typename C<S, T>::template B<U>::template E<D<F> > >
41A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g);
42