I have a class structure that uses a lot of templates that I want to use. I know that there are several similar questions on stack overflow ( Wrapping template template parameter class with SWIG , wrapping a specialized C ++ template class using swig .), But none of them worked for my case.
A minimal example is as follows
insane_template.h
#pragma once class CustomAttrs{ public: enum dattr1d{pos,vel,someCustomCaseVar, d1dLast}; }; template <class T> class A { public: T attributes; }; template <template<class> class A, class T> class B : public A<T> { }; template<template<template<class> class, class> class Op, template<class> class X, class T> class C : public Op<X,T> { }; template class A<CustomAttrs>; template class B<A, CustomAttrs>; template class C<B, A, CustomAttrs>;
My insane_template.i is pretty simple:
%module insane %{ #include "./insane_template.h" %} %include "./insane_template.h" %template(AC) A<CustomAttrs>; %template(BAC) B<A, CustomAttrs>; %template(CBAC) C<B, A, CustomAttrs>;
When I try to execute it via swig -v -c++ -python -outdir ./ nsane_template.i
, I get the error message Error: Syntax error in input(1).
If I comment on class C
, it works as expected. Unfortunately, this is one of the most needed classes to wrap.
So my question is: is there (and if so), then you can stroke the template design like template<template<template<class> class, class> class Op, template<class> class X, class T>
Is it right that the parser cannot parse such template constructors?
It would be nice if I only ran class C<B, A, CustomAttrs>
thanks a lot
UPDATE I am using swig 3.0.5 on ubuntu 14.04 with gcc / g ++ 4.8.4