派生自 development/c++

pansen
2018-12-18 42afa2b1a90ae47f75d69073294beaf6746fb401
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
45
46
47
48
49
50
51
//
// Created by ps on 8/9/18.
//
 
 
#include "ShareMemoryTool.hpp"
 
int main() {
 
//    char cc = '1';
//    for (int i = 0; i < 100; i++) {
//        cc++;
//        printf("%c \n", cc);
//    }
 
 
    try {
//        BISTL::shared_memory_object
        // init
//        BISTL::managed_shared_memory segment(BISTL::open_only, "aaa8" );
        BISTL::BiMapFeaData biMapFeaData("test");
 
//        const BISTL::void_allocator alloc_inst (segment.get_segment_manager());
 
//        BISTL::bi_map_Feature_Info * mymap =
//            segment.construct<BISTL::bi_map_Feature_Info>("MyMap")(std::less<BISTL::char_string>(),alloc_inst);
//        BISTL::bi_map_Feature_Info *mymap =
//            segment.find_or_construct<BISTL::bi_map_Feature_Info>("aaa8")(std::less<BISTL::char_string>(), alloc_inst);
 
        auto mymap = biMapFeaData.getMap();
        auto size = mymap->size();
        for (auto it = mymap->begin(); it != mymap->end(); it++) {
//            printf("%s \n", it->second.id.c_str());
//            printf("%d \n", it->second.id);
            std::cout << "id      " << it->second.m_id << std::endl;
            std::cout << "feature " << it->second.m_feature << std::endl;
//            it->second.id;
        }
        printf("\n");
 
//        BISTL::shared_memory_object::remove("SharedMemory");
    }
    catch (const std::exception &e) {
        printf("Exception:%s\n", e.what());
        BISTL::shared_memory_object::remove("test");
    }
    getchar();
    BISTL::shared_memory_object::remove("test");
 
    return 0;
}