Fix incorrectly shown warning for empty template instantiation used as a base class.

This commit is contained in:
William S Fulton 2017-08-02 22:55:23 +01:00
commit 2165f27f5d
4 changed files with 47 additions and 4 deletions

View file

@ -418,6 +418,7 @@ CPP_TEST_CASES += \
template_default_inherit \
template_default_qualify \
template_default_vw \
template_empty_inherit \
template_enum \
template_enum_ns_inherit \
template_enum_typedef \

View file

@ -0,0 +1,30 @@
%module template_empty_inherit
%inline %{
template<class Arg, typename Result> struct Functor {
virtual Result operator()(Arg x) const = 0;
};
%}
// 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<int, int>;
%template() Functor<int, int>;
%inline %{
#include <algorithm>
struct SquareFunctor : Functor<int, int> {
int operator()(int v) const { return v*v; }
};
%}
%include <std_vector.i>
%template(VectorInt) std::vector<int>;
%inline %{
std::vector<int> squares(const std::vector<int>& vi) {
std::vector<int> result;
std::transform(vi.begin(), vi.end(), std::back_inserter(result), SquareFunctor());
return result;
}
%}