I want to convert some C++ code to Java code in SWIG. In some C++ templates, there are some math operation about templates' parameters. Such as:
template<size_t nbits, size_t es>
value<1 + 2 * (nbits - es)> fma(const posit<nbits, es>& a, const posit<nbits, es>& b, const posit<nbits, es>& c);
The parameters, nbits and es, are used to calculate the parameters of template class value<...>. When I want to use %template(...) to instantiate the template function, fma, like this:
%template(fma_32_2) sw::unum::fma<32,2>;
However, it fails and display:
error: 'nbits' was not declared in this scope
SwigValueWrapper< sw::unum::value< 1+2*(nbits-es) > > result;
^~~~~
error: 'es' was not declared in this scope
SwigValueWrapper< sw::unum::value< 1+2*(nbits-es) > > result;
^~
error: template argument 1 is invalid
SwigValueWrapper< sw::unum::value< 1+2*(nbits-es) > > result;
^
error: template argument 1 is invalid
SwigValueWrapper< sw::unum::value< 1+2*(nbits-es) > > result;
So, is there any ways to fix it?