Reputation: 1758
I have a 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 to use boost.multiindex with three indexes: 1)user_id, 2)user_name, 3)address of the user_context object
I don't know, how to write key specification for address of the 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.
Upvotes: 0
Views: 256
Reputation: 5658
Use boost::multi_index::identity<user_context_ptr>
: two shared pointers are equivalent if they point to the same object (as it happens with regular pointers.)
Upvotes: 3