[multi_index] Problems with chained pointers in multi index from 1.34 RC

Hi, my multi_index use case: * The container contains not objects themselves, but pointers (shared_ptr-s). * The objects are noncopyable - they are created by a factory and only smart pointers are copied between clients. * The container has 2 indexes. Indexes are built on const_mem_fn extractor. One of the indexes uses a function from a base class. It seems that in 1.34 problem with using member function from a base class is supposed to be solved, but it causes a regression that you cannot have pointers to noncopyable objects in the container. Is this a known issue? My compiler is MSVC 7.1/Intel Compiler 9.0. Here is a code snippet to demonstrate the problem. This code compiles well with boost 1.33.1, but fails to compile with RC 1.34. If you uncomment the second index, it won't compile neither with 1.33 nor with 1.34. #include <boost/multi_index_container.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/shared_ptr.hpp> #include <boost/noncopyable.hpp> #include <iostream> #include <string> using namespace boost::multi_index; /* A name record consists of the given name (e.g. "Charlie") * and the family name (e.g. "Brown"). The full name, calculated * by name_record::name() is laid out in the "phonebook order" * family name + given_name. */ class base_record : boost::noncopyable { public: int get_id() const { return id_; } protected: base_record() : id_(0) {} private: int id_; }; class name_record : public base_record { public: typedef boost::shared_ptr<name_record> Ptr; static Ptr create() { return Ptr(new name_record()); } const std::string & name() const { return name_; } protected: name_record() : name_("") {} private: std::string name_; }; typedef multi_index_container< name_record::Ptr, indexed_by< ordered_unique< BOOST_MULTI_INDEX_CONST_MEM_FUN(name_record, const std::string &, name) /**/> // , // ordered_unique< // BOOST_MULTI_INDEX_CONST_MEM_FUN(base_record, int, get_id) // > /**/> /**/> name_record_set; int main() { name_record_set ns; ns.insert(name_record::create()); return 0; }

Alexei Alexandrov ha escrito:
Hi,
my multi_index use case: * The container contains not objects themselves, but pointers (shared_ptr-s). * The objects are noncopyable - they are created by a factory and only smart pointers are copied between clients. * The container has 2 indexes. Indexes are built on const_mem_fn extractor. One of the indexes uses a function from a base class.
It seems that in 1.34 problem with using member function from a base class is supposed to be solved, but it causes a regression that you cannot have pointers to noncopyable objects in the container. Is this a known issue?
My compiler is MSVC 7.1/Intel Compiler 9.0. Here is a code snippet to demonstrate the problem. This code compiles well with boost 1.33.1, but fails to compile with RC 1.34. If you uncomment the second index, it won't compile neither with 1.33 nor with 1.34.
Hello again, Alexei, after the illuminating discussion with Mr. Maddock I've realized that I'm using is_convertible in a suboptimal fashion with respect to the kind of convertibility I want to detect. Could you please run your snippet using the attached version of boost/multi_index/mem_fun.hpp? If I haven't done some mistake, this should make your code work, even with the second index uncommented. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
Hello again, Alexei, after the illuminating discussion with Mr. Maddock I've realized that I'm using is_convertible in a suboptimal fashion with respect to the kind of convertibility I want to detect. Could you please run your snippet using
the
attached version of boost/multi_index/mem_fun.hpp? If I haven't done some mistake, this should make your code work, even with the second index uncommented.
It compiles without the/a problem now! Both for the test code and for my real world application. Thank you very much - multi_index rocks the world once again... :-) Great support from your side is really one of the things why multi_index is so great. Alas, this is not the case with some other Boost libraries but it's a story for another day. P.S. Would you like me to try to get this specific test case into multi_index tests suite?

Alexei Alexandrov ha escrito:
JoaquÃn Mª López Muñoz <joaquin <at> tid.es> writes:
Hello again, Alexei, after the illuminating discussion with Mr. Maddock I've realized that I'm using is_convertible in a suboptimal fashion with respect to the kind of convertibility I want to detect. Could you please run your snippet using
the
attached version of boost/multi_index/mem_fun.hpp? If I haven't done some mistake, this should make your code work, even with the second index uncommented.
It compiles without the/a problem now! Both for the test code and for my real world application. Thank you very much - multi_index rocks the world once again... :-) Great support from your side is really one of the things why multi_index is so great. Alas, this is not the case with some other Boost libraries but it's a story for another day.
Thanks for the compliments! BTW, what do you use the lib for? (if you can disclose that info, of course.)
P.S. Would you like me to try to get this specific test case into multi_index tests suite?
No, it's not necessary, thanks for the offer --I'm already working on that, will commit today or tomorrow. Best regards, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz <joaquin <at> tid.es> writes:
Thanks for the compliments! BTW, what do you use the lib for? (if you can disclose that info, of course.)
I use it as kind of in-memory database - very simple for now but evolving. I fill the container using hash index and then I need to iterate over the elements by ordered indexes. At first, I was considering using std::hash_map extensions, but the problem is that I need it both on Windows and Linux and I have to use default MSVC and GCC STL - and their hash map-s are different. Moreover, on Windows I write for Itanium and AMD64/EM64T as well and STL that is shipped with Platform SDK for those architecture is pretty old - old (but not good) Dinkumware without any hash_map-s at all. So I needed universal solution for hash container for Windows/Linux all architectures. This is how I decided to evaluate boost.multi_index. And also, it's very amusing to dig through multi_index sources - it's like a puzzle...
participants (2)
-
Alexei Alexandrov
-
Joaquín Mª López Muñoz