OONumerics User :

From: Simon Perreault (nomis80_at_[hidden])
Date: 2006-03-27 17:58:15


On Monday 27 March 2006 14:32, Hari Sundar wrote:
> When I use gcc to compile this .. I get errors of the sort ..

Works for me, using GCc 4.0.2. I had to fix a few trivial syntax errors to
make it compile and I added a test function:

#include <iostream>

using namespace std;

class A {
    protected:
        float * some_data;
        int x;
        int y;
        int z;
};

template <typename T>
class B : public A
{
    public:
        T& asLeaf() { return static_cast<T&>(*this); }
        inline float SomeFunc(int i, int j, int k) {
            return asLeaf().SomeFunc(i,j,k);
        }
};

class C : public B<C>
{
    public:
        inline float SomeFunc(int i, int j, int k) {
            return some_data[k*x*y + j*x + i];
        }
};

template <typename T>
void f( B<T>& x )
{
    cout << x.SomeFunc(1,2,3) << endl;
}

void g()
{
    C c;
    f(c);
}