Difficult C++ template code (decorator pattern)

Here is a simple “Point” class with its accessor and decorator.
The program compiles easily with g++, but with pgCC doesn’t

Is it my fault (can anyone find a reason?) or pgCC does not support C++ templates in full?

Dominik

#include
#include

// Point data structure
template class Point {
public:
typedef T x_type;
x_type x;
typedef T y_type;
y_type y;
typedef T z_type;
z_type z;

Point(void) { x = y = z = 0; }
Point(T nx,T ny,T nz) { x = nx; y = ny; z = nz; }

friend std::ostream& operator<<(std::ostream& o, const Point& p){
o<<p.x<<" “<<p.y<<” “<<p.z<<”\n";
return o;
}
};

// An accessor class for the x field.
template< class T > class GetX {
public:
typedef T input_type;
typedef typename T::x_type output_type;
static output_type& get (input_type& v) { return v.x; }
static const output_type& get (const input_type& v) { return v.x; }
};

/*

  • Decorate a given iterator to go over a specified field in a class
  • Proper field is selected by accesor class.
    */
    template< class Decorated, template< class > class Access >
    class field_access: public Decorated {
    public:
    typedef typename Decorated::value_type value_type;
    typedef Access< value_type > accessor;
    typedef typename accessor::output_type output_type;
    field_access () : Decorated () {}
    field_access (const Decorated& d) : Decorated (d) {}

// Overload operator*, use the given accessor
// to get the proper field.
output_type& operator* () {
return accessor::get (Decorated::operator* ());
}
const output_type& operator* () const {
return accessor::get (Decorated::operator* ());
}
};

int main(void) {
GetX<Point > accesor_ix; // Declare an accesor to its X coordinate
std::vector<Point > c;

// Let’s make some points
for(unsigned i=0;i<10;i++) {
Point pi(i,i2,i3);
c.push_back(pi);
}

field_access< std::vector<Point >::iterator, GetX > // Prepare iterators
i, begin = c.begin (), end = c.end ();
for(i=begin;i!=end;++i) // Iterate over X and change them a bit
std::cout<<(*i)<<"\n";
}

dgront-

Our C++ compiler fully supports templates. Our STL iterator
struct, however is not defined in a manner that allows it to
be inherited. I have filed this as TPR 3533: we will fix this
to be compatible with gnu.

-Deborah Caruso