#include <iostream>
#include <boost/utility.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
struct Foo : boost::noncopyable
{
Foo() { std::cout << "made a Foo\n"; }
~Foo() { std::cout << "destroyed a Foo\n"; }
};
int main() {
boost::ptr_vector<Foo> foos;
foos.push_back(new Foo());
foos.push_back(new Foo());
foos.clear();
}
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