1 // Origin: PR c++/42824
2 // { dg-do compile }
3 
4 template<int T>
5 class int_ {
6 };
7 
8 template<int T, int T2>
9 class Unit {
10 public:
Unit(const Unit<T,T2> & other)11     Unit(const Unit<T, T2>& other) {}
12 };
13 
14 template<int T>
15 class Quan {
16 public:
Quan(void)17     Quan(void) {}
18 
19     template<int T2>
Quan(double value,Unit<T,T2> unit)20     Quan(double value, Unit<T, T2> unit) {}
21 };
22 typedef Quan<0> Scalar;
23 
24 template<int T>
25 class hlp {
26 public:
27    typedef Quan<T> type;
28 };
29 
30 class Mtrl {
31 public:
32     template<int T>
33     struct AssoType {
34         typedef typename hlp<T>::type type;
35     };
36 };
37 
38 template<class T>
39 class Eval {
40 public:
Eval(const T & object)41     Eval(const T& object){}
42 
43     template<int V>
eval()44     void eval() {
45         eval<V> (int_<0>());
46     }
47 private:
48     template<typename U> struct Wrap {};
49 
50     template<int V, int V2>
value(Wrap<Quan<V2>>)51     void value(Wrap<Quan<V2> >) {}
52 
53     template<int V>
value(Wrap<Scalar>)54     void value(Wrap<Scalar>) {}
55 
56     template<int V>
eval(int_<0>)57     void eval(int_<0>) {
58         typedef typename T::template AssoType<V>::type Type;
59         value<V>(Wrap<Type>());
60     }
61 };
62 
63 class Foo {
64 public:
eval(const Mtrl & mtrl)65     static void eval(const Mtrl& mtrl) {
66         Eval<Mtrl> h(mtrl);
67         h.eval<0> ();
68     }
69 };
70 
71