Re: SWIG syntax error on list initializer of template ctor parameter

William S Fulton <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <CANGqftARhyURnGYPea+tH59FmWj91Ks=5z1tu_qaD84Bu_7DvA@mail.gmail.com>
I thought it was a syntax error too at first in a function declaration,
which when corrected would be:

  const A<char, 3> A3(std::array<char, 3> = {'A','B','C'});

SWIG is equally confused I'm afraid, so please log this as a bug on Github.
You can work around it by declaring your variable using this syntax instead:

  const A<char, 3> A3 = A(std::array<char, 3>{'A','B','C'});

William

On Thu, 24 Sep 2020 at 07:36, <[email protected]> wrote:

> Meta-issue: Is it better to ask questions here, or on SO?  (SO is easier.)
>
> It's been awhile since I've done C++ coding, and I'm new to SWIG.  I posted
> my code to https://github.com/performantdata/swig-issue-2020-09/
>
> I'm trying to define an instance of a fully-specialized template and make
> it visible to Java.  The template ctor takes one parameter, a std::array.
> When I use a braced-init-list in the C++ header:
>
> ```
> const A<char, 3> A3(std::array<char, 3>{'A','B','C'});
> ```
>
> that seems fine to C++.  But when I specify that in the .i file, SWIG
> fails with "Error: Syntax error in input(1)."  If I remove the initializer
> list, SWIG succeeds, but the C++ compilation of the SWIG-generated wrapper
> fails, because it doesn't pass a parameter to the A ctor.
>
>
> _______________________________________________
> Swig-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/swig-user
>

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.