Boost logo

Boost Users :

Subject: [Boost-users] modify_key() for a composite_key of a multi_index_container that contains a shared_ptr
From: Zsolt Vajna (vzse_at_[hidden])
Date: 2009-10-02 03:00:07


I'd like to modify_key() for a composite_key of a multi_index_container that contains a shared_ptr.

I found a thread in this mailing list dealing with a similar kind of situation, not totally the same though: "[Boost-users] [multi_index] modify problem with composite_key"

My example:

This compiles fine:

struct entry
    {
        entry(int a, int b):m_x(a), m_y(b){}
        int m_x;
        int m_y;
    };
        
    typedef multi_index_container<
       entry,
       indexed_by<
         ordered_unique<
           composite_key<
             entry,
             member<entry,int,&entry::m_x>,
             member<entry,int,&entry::m_y>>>>> C;

void updateX(C::iterator iter,int x, C& m_c)
{
   m_c.get<0>().modify(
    iter, (&ll::_1)->*&entry::m_x=x);
}

My first problem is if I change modify to modify_key I get the following error:
operator_lambda_func_base.hpp(237) : error C3892: 'boost::lambda::detail::select' : you cannot assign to a variable that is const

My second problem is that instead of

typedef multi_index_container<
       entry,
       indexed_by<
         ordered_unique<
           composite_key<
             entry,
             member<entry,int,&entry::m_x>,
             member<entry,int,&entry::m_y>>>>> C;

i want to have a

typedef multi_index_container<
       shared_ptr<entry>,
       indexed_by<
         ordered_unique<
           composite_key<
             entry,
             member<entry,int,&entry::m_x>,
             member<entry,int,&entry::m_y>>>>> C;

Note the shared_ptr added.

In this later case I get another error:

boost\lambda\detail\member_ptr.hpp(512) : error C2440: 'newline' : cannot convert from 'const rt0 ' to 'entry *const '

I assume I need to change something around the _1 bit, but have no idea what.

Thanks

      


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net