-
Notifications
You must be signed in to change notification settings - Fork 0
/
animal.cpp
45 lines (36 loc) · 722 Bytes
/
animal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
#include <iostream>
#include <string>
using namespace boost::multi_index;
using namespace std;
struct animal
{
string name;
uint64_t legs;
};
typedef multi_index_container<
animal,
indexed_by<
hashed_non_unique<
member<
animal, string, &animal::name
>
>,
hashed_non_unique<
member<
animal, uint64_t, &animal::legs
>
>
>
> animal_multi;
int main() {
animal_multi animals;
animals.insert({"cat", 4});
animals.insert({"pigeon", 2});
animals.insert({"duck", 2});
animals.insert({"whale", 0});
cout << animals.count("pigeon") << endl;
return 0;
}