I would like to have something equivalent to C ++ std :: vector where the underlying objects are immutable. Therefore, I can use the push_back () functions to add them to a vector, etc. The actual std :: vector supports an array larger than the size of the vector filled with the default objects, and when you push_back (), it assigns the element to the array. My immutable objects do not have a default constructor, and assignment does not have a mutating operation, therefore, too.
I can do vector<boost::optional<T>> , but this is a dirty interface because I only want to place correctly constructed objects in the vector and deduce them from the vector.
I thought boost had something like this, but I could not find it. Does something like this exist?
source share