the C++ STL vector has a lot of decent properties, but only works when the size of each item is known at run-time.
I would like to have a vector class that features
Use std::vector where item is a wrapped smart pointer. The "item" class make a pointer look like a plain value :
class item {
private:
boost:unique_ptr p;
public:
// ...
public item(item that);
public int someFunction() {
// Forwarded
return p->somefunction();
}
};
class base {
virtual ~base();
// This is needed in order to implement copy of the item class
virtual base* clone();
};
public item::item(item that) : p(that.p.clone()) {}
class some_real_type() : public base {
// ....
}