Boost logo

Boost :

From: Allen (yaozhen_at_[hidden])
Date: 2005-07-28 10:40:20


I am using the ptr_container library (the version in the CVS) in my
current project recently. I am really suprised by the strange behaviour
of nullable ptr containers. If someone is using nullable ptr containers,
there always are needs to construct a ptr container with specific size
and filled in with all null pointers. 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
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.

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.

Am I missing something? Comments are welcome.

Best regards,

Yao, Zhen


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk