-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Small example:
`
//------------
struct employee
{
int id;
std::string name;
int age;
employee(int id_, std::string name_, int age_) :id(id_), name(name_), age(age_) {}
};
/* tags for accessing the corresponding indices of employee_set */
struct id {};
struct name {};
struct age {};
struct member {};
/* see Compiler specifics: Use of member_offset for info on
* BOOST_MULTI_INDEX_MEMBER
*/
/* Define a multi_index_container of employees with following indices:
* - a unique index sorted by employee::int,
* - a non-unique index sorted by employee::name,
* - a non-unique index sorted by employee::age.
*/
typedef multi_index_container<
employee,
indexed_by<
hashed_unique<
tag<id>, BOOST_MULTI_INDEX_MEMBER(employee, int, id)>,
ordered_non_unique<
tag<name>, BOOST_MULTI_INDEX_MEMBER(employee, std::string, name)>,
ordered_non_unique<
tag<age>, BOOST_MULTI_INDEX_MEMBER(employee, int, age)>
>
> employee_set;
employee_set es;
es.insert(employee(0, "Joe", 31));
es.insert(employee(1, "Robert", 27));
es.insert(employee(2, "John", 40));
es.insert(employee(2, "Aristotle", 2387));
es.insert(employee(3, "Albert", 20));
es.insert(employee(4, "John", 57));
employee_set es;
'
The items of the instance "es" are not shown in the Watch View of the Visual Studio debugger. Tested in version 2017, 2019 and 2022.
Metadata
Metadata
Assignees
Labels
No labels