Re: [boost] [review] Formal review of the Smart Container library

In-Reply-To: <797960166.20041007113153@topmail.sk> droba@topmail.sk (Pavol Droba) wrote (abridged):
Formal review of the Smart Containers library from Thorsten Ottosen has been extended until Saturday, October 7th 2004).
Goody. Here are my comments.
* What is your evaluation of the design?
I felt it was a bit muddled in its objectives. For example, it presents itself as a "container of pointers to heap-allocated objects", but then does not use pointer-like syntax or support NULL pointers. It offers both begin() and ptr_begin(). I feel there are really two kinds of container here. The first is a container of pointers which takes ownership of the objects it points to. This would be a more-or-less drop-in replacement for vector<T*>. It would allow nulls, and syntax like (*v.begin())->method(). The second is a container of values which may be polymorphic. It would be a more-or-less drop-in replacement for vector<T>. It would not allow nulls, and the syntax would be like v.begin()->method(). Although it would probably use pointers behind the scenes, that would be an implementation detail not revealed by its interface. The present submission has tried to combine these two kinds of container. I believe they would be better kept separate and given different names. I'd suggest "owning_vector" and "poly_vector", or similar, since the one is about ownership of pointers and the other is about solving the polymorphic value problem. Incidently, I also dislike the library calling itself "smart" because that word is too vague. Smart in what way? I am bothered by the libraries interaction with std algorithms. For example, std::remove_if<> doesn't work with the container's iterators. That makes it, at best, a low-level library that needs to be managed carefully.
* What is your evaluation of the potential usefulness of the library?
Why not use vector<shared_ptr<T> > instead? That provides a simple out-of-the-box solution without the problems with std algorithms. The present library claims performance benefits, but if I need those I'd write my own wrapper for vector<T *> which did exactly what I needed and no more. A library which made that easier might be useful to me, but I don't think the present submission is that library. The library also claims better syntax, but for me that benefit is negligible. So I don't believe I will ever use this library.
* What is your evaluation of the implementation? * What is your evaluation of the documentation? * Did you try to use the library? With what compiler? Did you have any problems? * How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? * Are you knowledgeable about the problem domain?
I have not looked at the implementation or attempted to use the library. I read the documentation, got confused, got unconfused via this list, and then decided it was not for me. Maybe half an hour of effort. I don't expect my opinion to carry much weight. I use std containers, and have often written wrappers for containers of raw pointers.
* Do you think the library should be accepted as a Boost library?
No. I strongly object to the library with its present naming. If it were renamed along the "poly_vector" lines, I would probably be neutral. -- Dave Harris, Nottingham, UK

Hi Dave, Thanks for your review. "Dave Harris" <brangdon@cix.compulink.co.uk> wrote in message news:memo.693392@cix.compulink.co.uk... | I feel there are really two kinds of container here. The first is a | container of pointers which takes ownership of the objects it points to. | This would be a more-or-less drop-in replacement for vector<T*>. It would | allow nulls, and syntax like (*v.begin())->method(). At some point it was discussed to have a new policy that decided the indirection of the reference type. It create much attention. Still it would not give a complete drop-in replacement. | The second is a container of values which may be polymorphic. It would be | a more-or-less drop-in replacement for vector<T>. It would not allow | nulls, and the syntax would be like v.begin()->method(). Although it would | probably use pointers behind the scenes, that would be an implementation | detail not revealed by its interface. | | The present submission has tried to combine these two kinds of container. | I believe they would be better kept separate and given different names. | I'd suggest "owning_vector" and "poly_vector", or similar, since the one | is about ownership of pointers and the other is about solving the | polymorphic value problem. poly_vector is not a bad name if that was the only uses of the containers. | Incidently, I also dislike the library calling itself "smart" because that | word is too vague. Smart in what way? smart in the same way smart pointers are smart. It should give the impression of exception-safety and resource ownership. | I am bothered by the libraries interaction with std algorithms. For | example, std::remove_if<> doesn't work with the container's iterators. | That makes it, at best, a low-level library that needs to be managed | carefully. Ok, what do you suggest we do instead? | | > * What is your evaluation of the potential usefulness of the | > library? | | Why not use vector<shared_ptr<T> > instead? That provides a simple | out-of-the-box solution without the problems with std algorithms. | | The present library claims performance benefits, but if I need those I'd | write my own wrapper for vector<T *> which did exactly what I needed and | no more. Could you enumerate what exactly you need and maybe tell why if a library suported more than you needed, but you didn't use that extra stuff, it would still be a bad thing? Would an unindirected interface be enough? (eg, you can determine to disable cloning etc). | I have not looked at the implementation or attempted to use the library. I | read the documentation, got confused, got unconfused via this list, and | then decided it was not for me. Maybe half an hour of effort. I don't | expect my opinion to carry much weight. | | I use std containers, and have often written wrappers for containers of | raw pointers. well, that is a least interesting. Did you ever forget to implement a wrapper function with the right exception-safety? | > * Do you think the library should be accepted as a Boost library? | | No. Sorry to hear that. Thanks for the review anyway best regards Thorsten

On Oct 9, 2004, at 8:46 AM, Dave Harris wrote:
The second is a container of values which may be polymorphic. It would be a more-or-less drop-in replacement for vector<T>. It would not allow nulls, and the syntax would be like v.begin()->method(). Although it would probably use pointers behind the scenes, that would be an implementation detail not revealed by its interface.
I.e. a vector<T&> ? -Howard

Howard Hinnant wrote:
On Oct 9, 2004, at 8:46 AM, Dave Harris wrote:
The second is a container of values which may be polymorphic. It would be a more-or-less drop-in replacement for vector<T>. It would not allow nulls, and the syntax would be like v.begin()->method(). Although it would probably use pointers behind the scenes, that would be an implementation detail not revealed by its interface.
I.e. a vector<T&> ?
Right! I'd often miss such a container, because I'd prefer references everywhere, but for vectors I need to use pointers. I supposed that ptr_vector with non-owning policy is exactly like vector<T&>. - Volodya
participants (4)
-
brangdon@cix.compulink.co.uk
-
Howard Hinnant
-
Thorsten Ottosen
-
Vladimir Prus