Boost logo

Boost Users :

Subject: Re: [Boost-users] Delete and free all elements of ptr_vector
From: Florian Lindner (mailinglists_at_[hidden])
Date: 2017-09-07 10:57:47


Thanks for your answer!

One more question: Is there a way to store an incomplete (forward declared) type. I get the compiler error message:

/home/florian/precice/src/mesh/Group.cpp:70:45: required from here
/usr/include/boost/ptr_container/detail/reversible_ptr_container.hpp:111:17: error: invalid use of incomplete type
'class precice::mesh::Vertex'
                 BOOST_ASSERT( typeid(*res) == typeid(*x) &&
In file included from /home/florian/precice/src/mesh/Group.cpp:1:0:
/home/florian/precice/src/mesh/Group.hpp:8:11: note: forward declaration of 'class precice::mesh::Vertex'
     class Vertex;
           ^~~~~~
In file included from /usr/include/boost/assert.hpp:58:0,
                 from /usr/include/boost/range/size.hpp:23,
                 from /usr/include/boost/range/functions.hpp:20,
                 from /usr/include/boost/ptr_container/detail/reversible_ptr_container.hpp:29,
                 from /usr/include/boost/ptr_container/ptr_sequence_adapter.hpp:20,
                 from /usr/include/boost/ptr_container/ptr_vector.hpp:20,
                 from /home/florian/precice/src/mesh/Group.hpp:4,
                 from /home/florian/precice/src/mesh/Group.cpp:1:
/usr/include/boost/ptr_container/detail/reversible_ptr_container.hpp:111:17: error: invalid use of incomplete type
'class precice::mesh::Vertex'
                 BOOST_ASSERT( typeid(*res) == typeid(*x) &&

So I assume no, or is there?

Thanks,
Florian

Am 07.09.2017 um 17:28 schrieb Thorsten Ottosen:
> Den 07-09-2017 kl. 11:09 skrev Florian Lindner via Boost-users:
>> Hello,
>>
>> in my project we have a simple ptr_vector that has a member function:
>>
>>     void deleteElements ()
>>     {
>>        for ( CONTENT_T * elem : _content ) {
>>           assertion ( elem != NULL );
>>           delete ( elem );
>>        }
>>     }
>>
>> I want to replace this ptr_vector with boost::ptr_vector. However, I haven't found a way to delete and free all pointers
>> stored in the container. How can I do that?
>
> boost::ptr_vector<Foo> container;
> ...
> container.clear()
>
> kind regards
>
> -Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net