c++ - boost.multiindex and addres of value as key -


i have struct:

struct user_context {    struct user_id;    struct user_name;    struct user_address;     boost::int64_t user_id() const;    const std::string& user_name() const; }; 

i want use boost.multiindex 3 indexes: 1)user_id, 2)user_name, 3)address of user_context object

i don't know, how write key specification address of object of user_context type.

typedef std::shared_ptr<user_context> user_context_ptr;  typedef boost::multi_index::multi_index_container<    user_context_ptr    ,boost::multi_index::indexed_by<        boost::multi_index::hashed_unique<            boost::multi_index::tag<user_context::user_id>           ,boost::multi_index::const_mem_fun<               user_context              ,boost::int64_t              ,&user_context::user_id            >        >,        boost::multi_index::hashed_unique<           boost::multi_index::tag<user_context::user_name>              ,boost::multi_index::const_mem_fun<                  user_context                 ,const std::string&                 ,&user_context::user_name              >         >,         boost::multi_index::hashed_unique<            boost::multi_index::tag<user_context::user_address>               ,boost::multi_index:: ??? <                      // <<<                   user_context                  ,user_context* (???)                          // <<<                  ,???                                          // <<<               >           >      > > users_container; 

thanks.

use boost::multi_index::identity<user_context_ptr>: 2 shared pointers equivalent if point same object (as happens regular pointers.)


Comments