Build error | resizing a vector of FunctionParsers

21 views
Skip to first unread message

vachanpo...@gmail.com

unread,
Jan 13, 2021, 1:23:34 AM1/13/21
to deal.II User Group

Dear all,

I require to use a vector of an array of FunctionParsers in my code

std::vector< std::array<FunctionParser<2>, 4> > fps_vec;

At a later point when I know its size, I call

fps_vec.resize(size);

This line produces a long build error message (attached) starting with

invalid application of ‘sizeof’ to incomplete type ‘mu::Parser’
  static_assert(sizeof(_Tp)>0,


If I comment out the resize line, then the remaining program compiles successfully. I noted that such an error occurs when the compiler is not able to see the object's declaration. But I already included the header file deal.II/base/function_parser.h. Wouldn't that point to relevant muparser's header file?

In a different file, I had used an std array of FunctionParsers and that worked fine. Doesn't that mean that the definition of mu::Parser is visible to compiler? I am unable to understand what is causing this error.

Is there any workaround for this? Thanks in advance!
error.log

Wells, David

unread,
Jan 13, 2021, 7:59:13 AM1/13/21
to deal.II User Group
Hi Vachan,

We explicitly disabled copying and moving instances of FunctionParser because it depends (for threaded parallelism) on several objects that cannot be copied or moved - that's why your code works as long as you don't try to resize the vector. The best workaround is to use

std::vector<std::unique_ptr<std::array<FunctionParser<2>, 4>>

(or switch the order of unique pointer and the array - what matters is that we move pointers instead of FunctionParser instances) so that no copies or moves are required.

Best,
David

From: dea...@googlegroups.com <dea...@googlegroups.com> on behalf of vachanpo...@gmail.com <vachanpo...@gmail.com>
Sent: Wednesday, January 13, 2021 1:23 AM
To: deal.II User Group <dea...@googlegroups.com>
Subject: [deal.II] Build error | resizing a vector of FunctionParsers
 
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/62d071e2-8bc9-4c44-8007-78e02f38e943n%40googlegroups.com.

vachanpo...@gmail.com

unread,
Jan 15, 2021, 6:43:42 AM1/15/21
to deal.II User Group
Thanks a lot David! This works!
Reply all
Reply to author
Forward
0 new messages