
Hi Allen, Allen <yaozhen <at> ustc.edu> writes:
However, I found that the ptr container can only "reserve" specfic sized buffered, but cannot be constructed with specific size:
ptr_vector<nullable<int> > v(10);
Instead, I have to write this:
ptr_vector<nullable<int> > v(10); for (int i = 0; i < 10; i++) v.push_back(0);
It is really a superise in my opinion, and write a loop (or use an STL algorithm) to fill the container manually is awkward and unnecessary.
I can't test this before I get a computer sgain. However, I think you should be able to use boost.assign to fill your ptr_vector.
I think it is more intuitive and natural that the above constructor constructs a ptr_vector of size 10, with 10 null pointers inside. If the container is not nullable, it could default-construct 10 objects (or clone 10 from a given one) instead.
the problem is that we don't want to make to much differences between ptr_vector<T> and ptr_vector< nullable<T> >. If one inserts clones, so should the other--and in my choice, vice versa. Let's see if boost.assign can't help you.
Another superise is it seems that the iterator returned by associative ptr containers are not std::pair like STL containers do, but the values in the associative container. I cannot see the reason for this incompatibility with STL, nor can I find any documentation or examples on this.
have you read the tutorial?
Am I missing something? Comments are welcome.
-Thorsten