Ticket #6720: main.cpp

File main.cpp, 715 bytes (added by Alexander Bessonov <alexbav@…>, 11 years ago)
Line 
1#include <memory>
2#include <boost/intrusive/unordered_set.hpp>
3
4namespace bi=boost::intrusive;
5
6class Item : public bi::unordered_set_base_hook<bi::link_mode<bi::safe_link>>
7{
8
9public:
10 struct hash
11 {
12 size_t operator()(const Item &s) const
13 {
14 return /* ... */ 0;
15 }
16 };
17};
18
19void main()
20{
21 typedef bi::unordered_set<
22 Item,
23 bi::constant_time_size<false>,
24 bi::hash<Item::hash>
25 > map_type;
26
27 std::unique_ptr<map_type::bucket_type[]> buckets;
28 std::unique_ptr<map_type> set;
29 buckets.reset(new map_type::bucket_type[50]);
30 set.reset(new map_type(map_type::bucket_traits(buckets.get(),50)));
31
32 // ... use the set
33
34 set->clear_and_dispose([](Item *ptr) { delete ptr; });
35}