////////////////////////////////////////////////////////////////////////////// // // (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 #include //[doc_named_allocB #include #include #include #include int main () { using namespace boost::interprocess; typedef std::pair MyType; try{ //An special shared memory where we can //construct objects associated with a name. //Connect to the already created shared memory segment //and initialize needed resources managed_shared_memory segment(open_only, "MySharedMemory"); std::pair res; //Find the array res = segment.find ("MyType array"); //Length should be 10 assert(res.second == 10); //Find the object res = segment.find ("MyType instance"); //Length should be 1 assert(res.second == 1); //Find the array constructed from iterators res = segment.find ("MyType array from it"); //Length should be 3 assert(res.second == 3); //Use data // . . . //We're done, delete all the objects segment.destroy("MyType array"); segment.destroy("MyType instance"); segment.destroy("MyType array from it"); } catch(...){ shared_memory_object::remove("MySharedMemory"); throw; } shared_memory_object::remove("MySharedMemory"); return 0; } //] #include