Hello, There seems to be a template problem in 2geom which is preventing OS X 10.3 (gcc 3.3) from compiling. This is an example of code which fails, simplified from 2geom/path.h and 2geom/svg-path.h:
//-------------------------------------- // build with: g++ -c -o test.o test.cpp class LineSegment; class Point;
class Path { public: template <typename CurveType, typename A> void appendNew(A a) { do_append(new CurveType((*final_)[0], a)); } };
template <typename OutputIterator> class SVGPathGenerator /*: public SVGPathSink*/ { public: void lineTo(Point p) { _path.appendNew<LineSegment>(p); //<---error: parse error before `;' token } protected: Path _path; }; //--------------------------------------
I can get this example to compile by making the whole Path class the template versus just the appendNew method, but it's not clear that making this change would be the right way to go in src/2geom/path.h.
Does anyone with template experience or 2geom knowledge have any ideas on how this might be simplified to make older compilers happy?
Thanks! , John
On Thu, 20 Dec 2007 12:42:26 -0800 "John Faith" <jfaith7@...400...> wrote:
Hello, There seems to be a template problem in 2geom which is preventing OS X 10.3 (gcc 3.3) from compiling. This is an example of code which fails, simplified from 2geom/path.h and 2geom/svg-path.h:
[...]
template <typename OutputIterator> class SVGPathGenerator /*: public SVGPathSink*/ { public: void lineTo(Point p) { _path.appendNew<LineSegment>(p); //<---error: parse error before `;' token }
Could you try and see if adding the "template" keyword before the method name makes any difference to the poor compiler? That is,
... void lineTo(Point p) { _path.template appendNew<LineSegment>(p); } ...
-- Gustav
On Dec 20, 2007 1:33 PM, Gustav Broberg <broberg@...370...> wrote:
On Thu, 20 Dec 2007 12:42:26 -0800 "John Faith" <jfaith7@...400...> wrote:
Hello, There seems to be a template problem in 2geom which is preventing OS X 10.3 (gcc 3.3) from compiling. This is an example of code which fails, simplified from 2geom/path.h and 2geom/svg-path.h:
[...]
template <typename OutputIterator> class SVGPathGenerator /*: public SVGPathSink*/ { public: void lineTo(Point p) { _path.appendNew<LineSegment>(p); //<---error: parse error before `;' token }
Could you try and see if adding the "template" keyword before the method name makes any difference to the poor compiler? That is,
... void lineTo(Point p) { _path.template appendNew<LineSegment>(p); } ...
Hi Gustav, That worked. I thank you, and my poor compiler thanks you!
Do you know if there an official term for this type of usage of "template?"
, John
participants (2)
-
Gustav Broberg
-
John Faith