so you have a class employee
class employee {
public:
employee(const string &name, int id) : m_name(name) , m_id(id) {}
const string &getName() const { return m_name; }
int getID() const { return m_id; }
private:
string &m_name;
int m_id;
};
and you have private data members for encapsulation. But now you want to use a boost::multi_index....
typedef multi_index_container <
employee,
indexed_by<
ordered_non_unique<
composite_key<
Name,
member< employee, string & , &employee::m_name>,
member< employee, int, &employee::m_id>
>
>
>
> employee_set;
so I could use BOOST_INDEX_CONST_MEM_FUN...
typedef multi_index_container <
employee,
indexed_by<
ordered_non_unique<
composite_key<
Name,
BOOST_MULTI_INDEX_CONST_MEM_FUN(employee, const string&, getName),
BOOST_MULTI_INDEX_CONST_MEM_FUN(employee, int, getID)
>
>
>
> employee_set;
but what I'd really like to do is to grant employee_set access to my employee class's private data members. I just can't figure out how to do it :-/