1 // PR c++/53581
2 
3 template<class A, int M, int N>
4 class Child;
5 
6 template<class A, int M, int N>
7 class Base
8 {
9 public:
10   Child<A, M, N> operator-(const Base<A, M, N> &m) const
11   {
12     Child<A, M, N> diff;
13     return diff;
14   }
15 
test()16   A test() const
17   {
18     return 0;
19   }
20 
21 private:
22   A values[M * N];
23 };
24 
25 template<class A, int N>
26 class Ops
27 {
28 public:
~Ops()29   virtual ~Ops() {}
30 
bar()31   bool bar() const
32   {
33     Child<A, N, N> mat;
34     return (*static_cast<const Child<A, N, N>*>(this) - mat).test();
35   }
36 };
37 
38 
39 template<class A, int N>
40 class Child<A, N, N> : public Base<A, N, N>, public Ops<A, N> {};
41 
42 class ImageWarp
43 {
bar()44   bool bar() const
45   {
46     return foo.bar();
47   }
48 
49   Child<float, 3, 3> foo;
50 };
51