I have set up a Windows C++ Visual Studio project (VS9) to test the use of Boost::Multi_Index. The container is being set up to store shared pointers to a custom object, FC::ClientOrder. For testing, the object is very simple, storing only a string and a char variable. Boost version is 1_46_0

I have configured the Multi_Index container to index on the shared pointer as the identity, and to also index on the two member variables, using member functions to access. That seems fine and works well.

I am having a problem with the modify() method though. I realise I have to use modify() if I want to update any member variables that are part of an index. I also realise that I have to locate the FC::ClientOrder object in the container first using find(), and then pass the iterator to modify() to make the change.

If I find the FC::ClientOrder shared pointer via the identity, the shared pointer itself, everything works well, and modify() is happy.

If I find the FC::ClientOrder shared pointer via the member function, clOrdID() (essentially looking up the order on it's ID, very common usage) then the modify() function fails, even though the syntax is identical. I get a compiler error, which seems to indicate a type issue, but I am finding it hard to understand what is wrong.

Will modify() only work with an iterator based on the identity index? If so, to edit the order via it's clOrdID, I would have to do two lookups, one to find the order in the container (and get it's spOrder variable) and one to then create an iterator based on the spOrder value. That seems to defeat the object of being able to pull up the order via the clOrdID() value.

I think I have misunderstood what the modify() function requires. For now, I can work around this by using the double lookup, but if anyone has a solution, I would greatly appreciate it. I am pretty new to Functors so maybe I have misunderstood what modify() needs.

Thanks in ad

Edit
Report