multi_index_test.cpp

来自「Boost provides free peer-reviewed portab」· C++ 代码 · 共 150 行

CPP
150
字号
////////////////////////////////////////////////////////////////////////////////// (C) Copyright Ion Gaztanaga 2006-2007. Distributed under the Boost// Software License, Version 1.0. (See accompanying file// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)//// See http://www.boost.org/libs/interprocess for documentation.////////////////////////////////////////////////////////////////////////////////#include <boost/interprocess/detail/config_begin.hpp>#include <boost/interprocess/detail/workaround.hpp>#include <boost/interprocess/managed_shared_memory.hpp>#include <boost/interprocess/allocators/allocator.hpp>#include <boost/interprocess/allocators/adaptive_pool.hpp>#include <boost/interprocess/allocators/cached_adaptive_pool.hpp>#include <boost/interprocess/allocators/private_adaptive_pool.hpp>#include <boost/interprocess/allocators/node_allocator.hpp>#include <boost/interprocess/allocators/cached_node_allocator.hpp>#include <boost/interprocess/allocators/private_node_allocator.hpp>#include <boost/interprocess/containers/string.hpp>#include <boost/multi_index_container.hpp>#include <boost/multi_index/member.hpp>#include <boost/multi_index/ordered_index.hpp>using namespace boost::interprocess;namespace bmi = boost::multi_index;typedef managed_shared_memory::allocator<char>::type              char_allocator;typedef basic_string<char, std::char_traits<char>, char_allocator>shm_string;//Data to insert in shared memorystruct employee{   int         id;   int         age;   shm_string  name;   employee( int id_           , int age_           , const char *name_           , const char_allocator &a)      : id(id_), age(age_), name(name_, a)   {}};//Tagsstruct id{};struct age{};struct name{};// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  allocator<employee,managed_shared_memory::segment_manager>>;// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  adaptive_pool<employee,managed_shared_memory::segment_manager>>;/*// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  cached_adaptive_pool<employee,managed_shared_memory::segment_manager>>;// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  private_adaptive_pool<employee,managed_shared_memory::segment_manager>>;*/// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  node_allocator<employee,managed_shared_memory::segment_manager>>;/*// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  cached_node_allocator<employee,managed_shared_memory::segment_manager>>;// Explicit instantiations to catch compile-time errorstemplate class bmi::multi_index_container<  employee,  bmi::indexed_by<    bmi::ordered_unique      <bmi::tag<id>,  BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,    bmi::ordered_non_unique<      bmi::tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>,    bmi::ordered_non_unique      <bmi::tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >,  private_node_allocator<employee,managed_shared_memory::segment_manager>>;*/int main (){   return 0;}#include <boost/interprocess/detail/config_end.hpp>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?