////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2004-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 #include #include #include #include #include #include #include #include "print_container.hpp" #include "movable_int.hpp" #include "dummy_test_allocator.hpp" #include "set_test.hpp" #include "map_test.hpp" #include "emplace_test.hpp" /////////////////////////////////////////////////////////////////// // // // This example repeats the same operations with std::set and // // shmem_set using the node allocator // // and compares the values of both containers // // // /////////////////////////////////////////////////////////////////// using namespace boost::interprocess; /* //Explicit instantiation to detect compilation errors template class boost::interprocess::set ,test::dummy_test_allocator >; template class boost::interprocess::map ,test::dummy_test_allocator > >; template class boost::interprocess::multiset ,test::dummy_test_allocator >; template class boost::interprocess::multimap ,test::dummy_test_allocator > >; */ //Customize managed_shared_memory class typedef basic_managed_shared_memory >, map_index > my_managed_shared_memory; //We will work with narrow characters for shared memory objects //Alias an integer node allocator type typedef allocator shmem_allocator_t; typedef allocator, my_managed_shared_memory::segment_manager> shmem_node_pair_allocator_t; typedef allocator shmem_movable_allocator_t; typedef allocator, my_managed_shared_memory::segment_manager> shmem_movable_node_pair_allocator_t; typedef allocator shmem_move_copy_allocator_t; typedef allocator, my_managed_shared_memory::segment_manager> shmem_move_copy_node_pair_allocator_t; //Alias standard types typedef std::set MyStdSet; typedef std::multiset MyStdMultiSet; typedef std::map MyStdMap; typedef std::multimap MyStdMultiMap; //Alias non-movable types typedef set, shmem_allocator_t> MyShmSet; typedef multiset, shmem_allocator_t> MyShmMultiSet; typedef map, shmem_node_pair_allocator_t> MyShmMap; typedef multimap, shmem_node_pair_allocator_t> MyShmMultiMap; //Alias movable types typedef set ,shmem_movable_allocator_t> MyMovableShmSet; typedef multiset, shmem_movable_allocator_t> MyMovableShmMultiSet; typedef map, shmem_movable_node_pair_allocator_t> MyMovableShmMap; typedef multimap, shmem_movable_node_pair_allocator_t> MyMovableShmMultiMap; typedef set ,shmem_move_copy_allocator_t> MyMoveCopyShmSet; typedef multiset, shmem_move_copy_allocator_t> MyMoveCopyShmMultiSet; typedef map ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMap; typedef multimap ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMultiMap; //Test recursive structures class recursive_set { public: int id_; set set_; friend bool operator< (const recursive_set &a, const recursive_set &b) { return a.id_ < b.id_; } }; class recursive_map { public: int id_; map map_; friend bool operator< (const recursive_map &a, const recursive_map &b) { return a.id_ < b.id_; } }; //Test recursive structures class recursive_multiset { public: int id_; multiset multiset_; friend bool operator< (const recursive_multiset &a, const recursive_multiset &b) { return a.id_ < b.id_; } }; class recursive_multimap { public: int id_; multimap multimap_; friend bool operator< (const recursive_multimap &a, const recursive_multimap &b) { return a.id_ < b.id_; } }; template void test_move_semantics() { //Now test move semantics C original; C move_ctor(detail::move_impl(original)); C move_assign; move_assign = detail::move_impl(move_ctor); move_assign.swap(detail::move_impl(original)); move_assign.swap(original); } int main () { //Recursive container instantiation { set set_; multiset multiset_; map map_; multimap multimap_; } //Now test move semantics { test_move_semantics >(); test_move_semantics >(); test_move_semantics >(); test_move_semantics >(); } using namespace boost::interprocess::detail; if(0 != test::set_test()){ return 1; } if(0 != test::set_test_copyable()){ return 1; } if(0 != test::set_test()){ return 1; } if(0 != test::set_test()){ return 1; } if (0 != test::map_test()){ return 1; } if(0 != test::map_test_copyable()){ return 1; } // if (0 != test::map_test()){ // return 1; // } if (0 != test::map_test()){ return 1; } const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC); if(!boost::interprocess::test::test_emplace, SetOptions>()) return 1; if(!boost::interprocess::test::test_emplace, SetOptions>()) return 1; const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR); if(!boost::interprocess::test::test_emplace, MapOptions>()) return 1; if(!boost::interprocess::test::test_emplace, MapOptions>()) return 1; return 0; } #include