////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2006-2012. 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 #include #include #include #include #include #include #include #include #include #include //<- //Shield against external warnings #include //-> #include #include #include //<- #include //-> using namespace boost::interprocess; namespace bmi = boost::multi_index; typedef managed_shared_memory::allocator::type char_allocator; typedef basic_string, char_allocator> shm_string; //Data to insert in shared memory struct employee { int id; int age; shm_string name; employee(const employee &e) : id(e.id), age(e.age), name(e.name) {} employee &operator=(const employee &e) { id = e.id; age = e.age; name = e.name; return *this; } employee( int id_ , int age_ , const char *name_ , const char_allocator &a) : id(id_), age(age_), name(name_, a) {} }; //Tags struct id{}; struct age{}; struct name{}; namespace boost { namespace multi_index { // Explicit instantiations to catch compile-time errors template class bmi::multi_index_container< employee, bmi::indexed_by< bmi::ordered_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, bmi::ordered_non_unique< bmi::tag,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>, bmi::ordered_non_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >, allocator >; // Explicit instantiations to catch compile-time errors template class bmi::multi_index_container< employee, bmi::indexed_by< bmi::ordered_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, bmi::ordered_non_unique< bmi::tag,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>, bmi::ordered_non_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >, adaptive_pool >; // Explicit instantiations to catch compile-time errors template class bmi::multi_index_container< employee, bmi::indexed_by< bmi::ordered_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, bmi::ordered_non_unique< bmi::tag,BOOST_MULTI_INDEX_MEMBER(employee,shm_string,name)>, bmi::ordered_non_unique , BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >, node_allocator >; }} int main () { return 0; } #include