boost.multiindex и адреса значения в качестве ключа

У меня есть структура:

struct user_context {
struct user_id;
struct user_name;
struct user_address;

boost::int64_t user_id() const;
const std::string& user_name() const;
};

Я хочу использовать Boost.MultiIndex с тремя индексами: 1) user_id, 2) user_name, 3) адрес объекта user_context

Я не знаю, как написать спецификацию ключа для адреса объекта типа user_context.

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;

Благодарю.

0

Решение

использование boost::multi_index::identity<user_context_ptr>: два общих указателя эквивалентны, если они указывают на один и тот же объект (как это происходит с обычными указателями).

3

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector