[containers] remarks and questions

Hello Ion, This is not a review. I took 3 hours to read the docs, checks some tests, try to check some sources, but I am still not used to read so few comments in the code. I played a little with the library then, tried to encapsulate some std::auto_ptr<X> in the new containers and things like that. Based on that very little experience, I would like to share some thoughts and ask a few questions on the proposed boost.containers library. 1/ I would really appreciate that the docs were more complete, at least for the technical part. => ex : "flat_map : more memory friendly and with faster searches" => In what way? is the algorithm complexity lesser than previous systems? or do you mean that contiguous memory is more cache-friendly? => do you provide different kernel implementations? => is there a paper on the subject? => Is there an evaluated algorithm complexity for the stable_vector? => is memory contiguous like a std::vector? can I use memcpy on several elements? These are just examples of questions that I expect to be answered by the docs. EDIT : I read proposition to embed elements of Joaquin M Lopez Munoz's blog. This is exactly that kind of informations I am looking for. => For the tree class, I can't remember any tree interface in the std. Could you point me to some informations ? Sorry If I miss something obvious. 2/ I was surprised (in a good way) to see some Andrei Alexandrescu's code in the library. Will the Loki licence be shipped now with boost? (This is not a problem for me). 3/ A few tests might be added. ex: Test the fact the vector usually are contiguous in memory. I can write this one if you are interested. 4/ The 'move aware' containers are nice to use but as a drawback We are forced to use macro to define the types using the 'move' semantics. What other container libraries can this work be related to? There are some examples of containers requiring the value_type to support only the "defaut constructor + a swap() function". This is a concept I would really appreciate to see in boost.containers. In that case, I would very happily use this library. Otherwise I think I will stick with other containers classes. 5/ "The aim of the library is to offers advanced features" Is the proposed Boost.containers also an effort towards development of new features for containers? If that is the case, then what are the plans for the future ? Is there a roadmap? To sum up : I am surprised that such a container library was not already integrated in boost. This should be a nice addition. But at the moment I don't think I would use it: my main interest would be for the value_type supporting "defaut constructor + a swap() function" to be added to the library. I also would like more detais in the documentation. In my humble opinion, it would also be easier for exterior people to learn from and to contribute to your library if there were more comments in the code. I congratulate you and the other authors for your work and efforts, and wish you the best for the review. Best regards, Pierre Morcello -- View this message in context: http://boost.2283326.n4.nabble.com/boost-containers-remarks-and-questions-tp... Sent from the Boost - Dev mailing list archive at Nabble.com.

El 08/08/2011 23:48, Pierre Morcello escribió:
Hello Ion,
This is not a review.
I took 3 hours to read the docs, checks some tests, try to check some sources, but I am still not used to read so few comments in the code. I played a little with the library then, tried to encapsulate some std::auto_ptr<X> in the new containers and things like that.
Thanks for taking your valuable time ;-)
Based on that very little experience, I would like to share some thoughts and ask a few questions on the proposed boost.containers library.
Go ahead.
1/ I would really appreciate that the docs were more complete, at least for the technical part. => ex : "flat_map : more memory friendly and with faster searches" => In what way? is the algorithm complexity lesser than previous systems? or do you mean that contiguous memory is more cache-friendly? => do you provide different kernel implementations? => is there a paper on the subject? => Is there an evaluated algorithm complexity for the stable_vector? => is memory contiguous like a std::vector? can I use memcpy on several elements? These are just examples of questions that I expect to be answered by the docs.
Ok, this was already mentioned in previous reviews. I'll add new chapters for non-standard containers like flat_xxx, stable_vector and slist.
EDIT : I read proposition to embed elements of Joaquin M Lopez Munoz's blog. This is exactly that kind of informations I am looking for.
Ok
=> For the tree class, I can't remember any tree interface in the std. Could you point me to some informations ? Sorry If I miss something obvious.
No, there is not, it's just that all (ordered) associative containers were implemented as rbtrees.
2/ I was surprised (in a good way) to see some Andrei Alexandrescu's code in the library. Will the Loki licence be shipped now with boost? (This is not a problem for me).
Although originally I started with Loki code, current code is a complete rewrote (priv_insert_commit, etc. are concepts taken from Intrusive). It's just that I never changed the licencse like I did with SGI license note from vector. Nevertheless, the inspiration from Loki should be mentioned as the idea for a drop-in replacement for associative containers came from Loki::AssocVector.
3/ A few tests might be added. ex: Test the fact the vector usually are contiguous in memory. I can write this one if you are interested.
Patches welcome ;-)
4/ The 'move aware' containers are nice to use but as a drawback We are forced to use macro to define the types using the 'move' semantics.
We'll, it's the portable Boost.Move syntax. If you have a C++11 container you can directly use rvalue references. For C++03 code is much uglier to write than using macros :-(
What other container libraries can this work be related to?
Talking about portable containers, according libc++ (http://libcxx.llvm.org/), a high quality standard library requiring C++11 compiler, "STLport and the Apache libstdcxx library are two other popular candidates, but both lack C++'0x support. Our experience (and the experience of libstdc++ developers) is that adding support for C++0x (in particular rvalue references and move-only types) requires changes to almost every class and function, essentially amounting to a rewrite." "Further, both projects are apparently abandoned: STLport 5.2.1 was released in Oct'08, and STDCXX 4.2.1 in May'08." Boost.Container has some C++0x support and plans to support all C++11 features plus backport as much as possible (like we've already done with emplace, move semantics..) to C++03 compilers. For C++03 code STLport added some optimizations like "move semantic for STL containers combination like vector of vector", but I don't know if these optimizations are open to user-defined classes. list and other containers don't seem to support this.
There are some examples of containers requiring the value_type to support only the "defaut constructor + a swap() function". This is a concept I would really appreciate to see in boost.containers. In that case, I would very happily use this library. Otherwise I think I will stick with other containers classes.
Yes, default-contruct only types are supported in many operations, just like C++11 requires (say, resize(), emplace()...). I'll add this requirement to each function description.
5/ "The aim of the library is to offers advanced features" Is the proposed Boost.containers also an effort towards development of new features for containers? If that is the case, then what are the plans for the future ? Is there a roadmap?
At this moment, the goal is to fully support C++11 and backport as much as possible to C++03. After that, we can start experimenting new features (say, allocator improvements) or containers (just like stable_vector and flat_xxx family).
In my humble opinion, it would also be easier for exterior people to learn from and to contribute to your library if there were more comments in the code.
Most of code relies on Boost.Intrusive, but I'll add comments to code.
I congratulate you and the other authors for your work and efforts, and wish you the best for the review.
Thanks for your help! Ion

Hi Ion, Thanks for the detailed answer.
(Me) There are some examples of containers requiring the value_type to support only the "defaut constructor + a swap() function". This is a concept I would really appreciate to see in boost.containers. In that case, I would very happily use this library. Otherwise I think I will stick with other containers classes.
Yes, default-contruct only types are supported in many operations, just like C++11 requires (say, resize(), emplace()...). I'll add this requirement to each function description.
Maybe I was not clear. What I meant was the same as the dlibc++ containers : being able to use a class like in the following example. //------------------------------------------------------// #include <boost/container/vector.hpp> #include <iostream> // defaut constructor, swap, and destructor are available, and other functions are hidden. class swapOnly { public: swapOnly():i(0){} void swap(swapOnly& p){ std::swap(p.i, i);} private: int i; swapOnly(const swapOnly&); swapOnly& operator=(const swapOnly&); }; int main() { boost::container::vector< swapOnly > swapOnlys(3); return 0; } //------------------------------------------------------// That is what I meant : a container able also to use only the value_type::value_type() and value_type::swap() function to implement its internal operations. This does not compile. As a consequence, I think such concept is not supported by boost.containers at the moment. What is your point of view on that matter ? Did I miss something? Best regards, Pierre Morcello -- View this message in context: http://boost.2283326.n4.nabble.com/boost-containers-remarks-and-questions-tp... Sent from the Boost - Dev mailing list archive at Nabble.com.

El 12/08/2011 0:40, Pierre Morcello escribió:
Hi Ion,
Thanks for the detailed answer.
(Me) There are some examples of containers requiring the value_type to support only the "defaut constructor + a swap() function". This is a concept I would really appreciate to see in boost.containers. In that case, I would very happily use this library. Otherwise I think I will stick with other containers classes.
Yes, default-contruct only types are supported in many operations, just like C++11 requires (say, resize(), emplace()...). I'll add this requirement to each function description.
Maybe I was not clear. What I meant was the same as the dlibc++ containers : being able to use a class like in the following example.
It's a bug, Boost.Container should support it. It works for list and other containers but not for vector. I plan to support non-copyable and non-movable types, as the new standard requires it for several operations. Best, Ion
participants (2)
-
Ion Gaztañaga
-
Pierre Morcello