C++ Templates and SWIG

Hi,

I am probably going to need some templates in C++ blocks in the near
future, so I had a look at the code in gnuradio-core, where the
templates are processed before the compiler gets to see the code (all
the *X.cc.t files). If I read correctly, there was some discussion a
while ago to change this to C++ templates.

Question: could this now be done with C++ templates, or is there a
(SWIGgy) reason to use the custom template system?

TIA,
MB

On Tue, Jan 20, 2009 at 7:53 AM, Martin B.
[email protected] wrote:

I am probably going to need some templates in C++ blocks in the near
future, so I had a look at the code in gnuradio-core, where the
templates are processed before the compiler gets to see the code (all
the *X.cc.t files). If I read correctly, there was some discussion a
while ago to change this to C++ templates.

Question: could this now be done with C++ templates, or is there a
(SWIGgy) reason to use the custom template system?

The original reason this was done was that SWIG did not work very well
with C++ templates and it was simpler and easier to implement our own
technique. SWIG has come along way and the original justification may
not hold anymore.

We’re open to suggestions in this area. I think Michael D. at
one point had some ideas here.

-Johnathan

Hi Martin -

On Jan 20, 2009, at 10:53 AM, Martin B. wrote:

I am probably going to need some templates in C++ blocks in the near
future, so I had a look at the code in gnuradio-core, where the
templates are processed before the compiler gets to see the code (all
the *X.cc.t files). If I read correctly, there was some discussion a
while ago to change this to C++ templates.

Yes, see <
http://lists.gnu.org/archive/html/discuss-gnuradio/2007-08/msg00361.html

and follow-up threads. Maybe Eric or Johnathan can chime in on
any transition plans or thoughts?

Question: could this now be done with C++ templates, or is there a
(SWIGgy) reason to use the custom template system?

I’ve done this in my personal block making space; it works cleanly and
well in those cases I’ve tried. That said, I’m sure there are cases
where using GR’s template method makes more sense. Further, using C++
templates can result in messy and/or non-obvious programming … I
don’t have a good examples, but I’m confident that these are the cases
since they’re part of the “power of C++”. - MLD