[C++-sig] Re: pyste and template functions

John Hunter jdhunter at ace.bsd.uchicago.edu
Tue Nov 9 16:47:46 CET 2004

>>>>> "David" == David Abrahams <dave at boost-consulting.com> writes:

    David> I'm not sure what you're doing that isn't working, though.
    David> You only showed what worked.

Oops.  I tried following the approach for template classes

    Intersect = Template("agg::intersect_rectangles", "agg_basics.h")
    Intersect("agg::rect", "intersect_rectangles")
    Intersect("agg::rect_d", "intersect_rectangles_d")

where the signature for the template function intersect_rectangles is

    template<class Rect> 
    inline Rect intersect_rectangles(const Rect& r1, const Rect& r2)

pyste generates the following code (line number 321 marked for
compiler error reference below)

321-> typedef agg::intersect_rectangles< agg::rect > intersect_rectangles;
      void __instantiate_intersect_rectangles()
      { sizeof(intersect_rectangles); }

      typedef agg::intersect_rectangles< agg::rect_d > intersect_rectangles_d;
      void __instantiate_intersect_rectangles_d()
      { sizeof(intersect_rectangles_d); }

which causes gccxml to die with 

    /tmp/tmpcfn9df.h:321: error: syntax error before `;' token
    /tmp/tmpcfn9df.h: In function `void __instantiate_intersect_rectangles()':
    /tmp/tmpcfn9df.h:323: error: ISO C++ forbids applying `sizeof' to an expression
    of function type

where line 321 is indicated above.

I assumed thusly that pyste either did not handle template functions
or at least I didn't know how to handle them in pyste, so I reverted
to the module_code I mentioned above.


More information about the Cplusplus-sig mailing list