Compilation error: use of deleted function

193 views
Skip to first unread message

Michał Wichrowski

unread,
Sep 21, 2018, 7:22:31 AM9/21/18
to deal.II User Group
Dear all,

I have errors when compiling my code with the devellpment version of deal.II .  The same problems occurs also with 9.0.0, the code works well with 9.0.0-pre. I  have no idea how to resolve these problems.

Michał 

/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:137:7: error: use of deleted function ‘dealii::mg::Signals::Signals(const dealii::mg::Signals&)’
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: note: ‘dealii::mg::Signals::Signals(const dealii::mg::Signals&)’ is implicitly deleted because the default definition would be ill-formed:
   struct Signals
          ^
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool)>::signal(const boost::signals2::signal<void(bool)>&)’
In file included from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/slot.hpp:21:0,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/connection.hpp:24,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/signal.hpp:22,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2.hpp:19,
                 from /home/mwichro/lib/deal.II/include/deal.II/lac/solver.h:27,
                 from /home/mwichro/lib/deal.II/include/deal.II/lac/solver_cg.h:26,
                 from /home/mwichro/deal.II-projects/StokeMatrixFree/StokesMatrixFree.cc:8:
/home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/detail/signal_template.hpp:599:11: note: ‘boost::signals2::signal<void(bool)>::signal(const boost::signals2::signal<void(bool)>&)’ is implicitly declared as deleted because ‘boost::signals2::signal<void(bool)>’ declares a move constructor or move assignment operator
     class BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
           ^
In file included from /home/mwichro/deal.II-projects/StokeMatrixFree/StokesMatrixFree.cc:34:0:
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool)>::signal(const boost::signals2::signal<void(bool)>&)’
   struct Signals
          ^
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’
In file included from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/slot.hpp:21:0,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/connection.hpp:24,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/signal.hpp:22,
                 from /home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2.hpp:19,
                 from /home/mwichro/lib/deal.II/include/deal.II/lac/solver.h:27,
                 from /home/mwichro/lib/deal.II/include/deal.II/lac/solver_cg.h:26,
                 from /home/mwichro/deal.II-projects/StokeMatrixFree/StokesMatrixFree.cc:8:
/home/mwichro/lib/deal.II/include/deal.II/bundled/boost/signals2/detail/signal_template.hpp:599:11: note: ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’ is implicitly declared as deleted because ‘boost::signals2::signal<void(bool, unsigned int)>’ declares a move constructor or move assignment operator
     class BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
           ^
In file included from /home/mwichro/deal.II-projects/StokeMatrixFree/StokesMatrixFree.cc:34:0:
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’
   struct Signals
          ^
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’
/home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:53:10: error: use of deleted function ‘boost::signals2::signal<void(bool, unsigned int)>::signal(const boost::signals2::signal<void(bool, unsigned int)>&)’

Wolfgang Bangerth

unread,
Sep 21, 2018, 5:53:42 PM9/21/18
to dea...@googlegroups.com
On 09/21/2018 05:22 AM, Michał Wichrowski wrote:
> Dear all,
>
> I have errors when compiling my code with the devellpment version of
> deal.II .  The same problems occurs also with 9.0.0, the code works well
> with 9.0.0-pre. I  have no idea how to resolve these problems.
>
> Michał
>
> /home/mwichro/lib/deal.II/include/deal.II/multigrid/multigrid.h:137:7:
> error: use of deleted function ‘dealii::mg::Signals::Signals(const
> dealii::mg::Signals&)’

Michal,
the error is in your code, but since I don't have it, I can't tell
where. I suspect that you are trying to copy an object of type
Multigrid, in StokeMatrixFree/StokesMatrixFree.cc:34 of your project.
This copy may happen implicitly if you call a function that takes a
Multigrid object by value, rather than by reference. (Or does so for an
object that has a Multigrid object as a member variable.)

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Michał Wichrowski

unread,
Sep 25, 2018, 7:56:25 AM9/25/18
to deal.II User Group
Michal,
the error is in your code, but since I don't have it, I can't tell
where. I suspect that you are trying to copy an object of type
Multigrid, in StokeMatrixFree/StokesMatrixFree.cc:34 of your project.
This copy may happen implicitly if you call a function that takes a
Multigrid object by value, rather than by reference. (Or does so for an
object that has a Multigrid object as a member variable.)

Best
  W.

Yep, I am trying to copy Multigrid object on purpose, I found the line corresponding to the  problem:
Line 762:
  std::vector<Multigrid<LevelVectorType > >  multigrids_sc(triangulation.n_global_levels(),
  mg_sc);

 I need a vector of objects of type Multigrid, how can I fix this?

Wolfgang Bangerth

unread,
Sep 25, 2018, 9:30:06 AM9/25/18
to dea...@googlegroups.com
On 09/25/2018 05:56 AM, Michał Wichrowski wrote:
>
> Yep, I am trying to copy Multigrid object on purpose, I found the line
> corresponding to the  problem:
> Line 762:
>   std::vector<Multigrid<LevelVectorType > >
> multigrids_sc(triangulation.n_global_levels(),
>   mg_sc);
>
>  I need a vector of objects of type Multigrid, how can I fix this?

Do you actually need to copy the Multigrid objects, or do you just want to
store them in a vector? (std::vector of course requires its objects to be
copiable.)

If you don't actually need copies, then just use a
std::vector<std::unique_ptr<Multigrid>>.

Michał Wichrowski

unread,
Sep 25, 2018, 9:38:30 AM9/25/18
to deal.II User Group


W dniu wtorek, 25 września 2018 15:30:06 UTC+2 użytkownik Wolfgang Bangerth napisał:
On 09/25/2018 05:56 AM, Michał Wichrowski wrote:
>
> Yep, I am trying to copy Multigrid object on purpose, I found the line
> corresponding to the  problem:
> Line 762:
>    std::vector<Multigrid<LevelVectorType > >  
> multigrids_sc(triangulation.n_global_levels(),
>    mg_sc);
>
>   I need a vector of objects of type Multigrid, how can I fix this?

Do you actually need to copy the Multigrid objects, or do you just want to
store them in a vector? (std::vector of course requires its objects to be
copiable.)

If you don't actually need copies, then just use a
std::vector<std::unique_ptr<Multigrid>>.

Best
  W.

Yes, I need triangulation.n_global_levels() copies of multigrid. I modify each of them in next line:

  std::vector<Multigrid<LevelVectorType > >  multigrids_sc(triangulation.n_global_levels(),
  mg_sc);
  for (unsigned int level = 0; level<triangulation.n_global_levels(); ++level)
  multigrids_sc[level].reinit(0, level);

Wolfgang Bangerth

unread,
Sep 25, 2018, 9:49:24 AM9/25/18
to dea...@googlegroups.com
On 09/25/2018 07:38 AM, Michał Wichrowski wrote:
>
>
> Yes, I need triangulation.n_global_levels() copies of multigrid. I modify each
> of them in next line:
>
>   std::vector<Multigrid<LevelVectorType > >
> multigrids_sc(triangulation.n_global_levels(),
>   mg_sc);
>   for (unsigned int level = 0; level<triangulation.n_global_levels(); ++level)
>   multigrids_sc[level].reinit(0, level);

I know you need this many objects, but what I meant is: do you actually need
to copy one object to another? If you use a std::vector<std::unique_ptr<...>>,
you can also have as many copies as you showed.

Michał Wichrowski

unread,
Sep 25, 2018, 10:33:57 AM9/25/18
to deal.II User Group
On 09/25/2018 07:38 AM, Michał Wichrowski wrote:
>
>
> Yes, I need triangulation.n_global_levels() copies of multigrid. I modify each
> of them in next line:
>
>    std::vector<Multigrid<LevelVectorType > >  
> multigrids_sc(triangulation.n_global_levels(),
>    mg_sc);
>    for (unsigned int level = 0; level<triangulation.n_global_levels(); ++level)
>    multigrids_sc[level].reinit(0, level);

I know you need this many objects, but what I meant is: do you actually need
to copy one object to another? If you use a std::vector<std::unique_ptr<...>>,
you can also have as many copies as you showed.

Best
  W.

Ok, now I understand the idea. I do not need to copy a specific object, just several Multigrid objects, so it should work.
If I understand correctly, I should do something like this:
  std::vector<std::unique_ptr<Multigrid<LevelVectorType >  > >
    multigrids_sc_pointers(triangulation.n_global_levels());
  for (unsigned int level = 0; level<triangulation.n_global_levels(); ++level)
  multigrids_sc_pointers[level] =  new Multigrid<LevelVectorType >(
    mg_matrix_sc,
    mg_coarse_sc,
mg_transfer_sc,
mg_smoother_sc,
mg_smoother_sc);
It does not work, I have almost no experience with unique pointers and I have no idea how to do it. Could you help me? 
Thanks

Daniel Arndt

unread,
Sep 25, 2018, 11:41:21 AM9/25/18
to deal.II User Group
Michal.
 
Ok, now I understand the idea. I do not need to copy a specific object, just several Multigrid objects, so it should work.
If I understand correctly, I should do something like this:
  std::vector<std::unique_ptr<Multigrid<LevelVectorType >  > >
    multigrids_sc_pointers(triangulation.n_global_levels());
  for (unsigned int level = 0; level<triangulation.n_global_levels(); ++level)
  multigrids_sc_pointers[level] =  new Multigrid<LevelVectorType >(
    mg_matrix_sc,
    mg_coarse_sc,
mg_transfer_sc,
mg_smoother_sc,
mg_smoother_sc);
It does not work, I have almost no experience with unique pointers and I have no idea how to do it. Could you help me? 
What exactly is not working? In which line do you get an error message? What does it say?

Best,
Daniel

Wolfgang Bangerth

unread,
Sep 25, 2018, 2:59:41 PM9/25/18
to dea...@googlegroups.com
On 09/25/2018 08:33 AM, Michał Wichrowski wrote:
>   multigrids_sc_pointers[level] =  new Multigrid<LevelVectorType >(
>     mg_matrix_sc,
>     mg_coarse_sc,
> mg_transfer_sc,
> mg_smoother_sc,
> mg_smoother_sc);

This won't compile. You'll have to write this as

multigrids_sc_pointers[level] =
std_cxx14::make_unique<Multigrid<LevelVectorType>>(
mg_matrix_sc,
mg_coarse_sc,
mg_transfer_sc,
mg_smoother_sc,
mg_smoother_sc);

Michał Wichrowski

unread,
Sep 26, 2018, 6:39:51 AM9/26/18
to deal.II User Group
It works
Thank You
Michał
Reply all
Reply to author
Forward
0 new messages