%module template_empty_inherit %rename(FunctorOperator) operator(); %inline %{ template struct Functor { virtual Result operator()(Arg x) const = 0; virtual ~Functor() {} }; %} // Bug fix - %ignore was resulting in this warning: // Warning 401: Base class 'Functor< int,int >' has no name as it is an empty template instantiated with '%template()'. Ignored. %ignore Functor; %template() Functor; %inline %{ #include #include struct SquareFunctor : Functor { int operator()(int v) const { return v*v; } }; %} %include %template(VectorInt) std::vector; %inline %{ std::vector squares(const std::vector& vi) { std::vector result; std::transform(vi.begin(), vi.end(), std::back_inserter(result), SquareFunctor()); return result; } %}