[Interprocess][Container] nested containers and scoped allocators

Hi, First of all my setup: I am compiling on redhat 6 with clang 3.4 in C++03, using boost_1_58. In a project of mine I am using a map<int, vector<int>> (types to be stored in shared memory and I am using the proper allocators as per interprocess documentation). If mymap is an instance of such a type, then mymap[0] is an invalid syntax because of issues that, to the best of my understanding, are related to the fact that the map tries to use the default constructor (with the default allocator) for the nested type as operator[] also accounts for the case in which the entry is missing and must be constructed. Using at() instead of operator[] makes the whole thing compile. On construction, I give the usual instance of allocator<void, segment_manager> to mymap. According to what I read in Boost.Container docs: http://www.boost.org/doc/libs/1_58_0/doc/html/container/Cpp11_conformance.ht... It would seem to me that a scoped allocator is a mechanism by which the allocator I gave to mymap is passed down to the nested vector. In which case I would expect operator[] to try to use such allocator instead of the default one. But then again, I always do mymap.insert(std::pair<const int, vector<int,...>>(0, vector<...>(my_void_alloc))) to add an element to the map, since I need to specify the allocator (and the examples in interprocess use this syntax). Given all of this, I would be grateful for any insight into the following: 1. If the scoped allocator is meant to be passed from the map to the vector, why can I not use operator[] and I necessarily need to use insert() to create a new vector in the map? Have I misunderstood what a scoped allocator is? Thanks in advance. -- View this message in context: http://boost.2283326.n4.nabble.com/Interprocess-Container-nested-containers-... Sent from the Boost - Users mailing list archive at Nabble.com.

::vector_alloc_holder' requested here : m_holder() ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/detail/value_init.hpp:35:9: note: in instantiation of member function 'boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > >::vector' requested here : m_t() ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/flat_map.hpp:1060:52: note: in instantiation of member function 'boost::container::container_detail::value_init<boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > > >::value_init' requested here container_detail::value_init<mapped_type> m; ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/flat_map.hpp:598:82: note: in instantiation of member function 'boost::container::flat_map<int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > >, std::less<int>, boost::interprocess::allocator<std::pair<int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > >::priv_subscript' requested here BOOST_MOVE_CONVERSION_AWARE_CATCH( operator[] , key_type, mapped_type&,
I said something wrong when I said that the compiler tries to use the default constructor. What happens is that it can not match the correct allocator and hence fails to find a valid constructor. Let me link the compiler output to clarify what happens when I use operator[] instead of at(). In bold is the one that should be used but it is deemed not valid: In file included from /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/interprocess/containers/flat_map.hpp:23: In file included from /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/flat_map.hpp:29: In file included from /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/detail/flat_tree.hpp:30: /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/vector.hpp:301:9: error: no matching constructor for initialization of 'boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> >' : Allocator(), m_start(), m_size(), m_capacity() ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/container/vector.hpp:725:9: note: in instantiation of member function 'boost::container::container_detail::vector_alloc_holder<boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> >, boost::container::container_detail::integral_constant<unsigned int, 2> this->priv_subscript) ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/move/detail/move_helpers.hpp:42:14: note: expanded from macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH' { return FWD_FUNCTION(static_cast<const TYPE&>(x)); }\ ^ include/LVCNext/CacheLayout.hxx:191:9: note: in instantiation of member function 'boost::container::flat_map<int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > >, std::less<int>, boost::interprocess::allocator<std::pair<int, boost::container::vector<int, boost::interprocess::allocator<int, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > > >, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0>, 0>, iset_index> > >::operator[]' requested here sync_policy::edit_data(m_cache_layout)[cache_itr->first][*record_itr] = type_resize_value; ^ /home/user/mbravi/Current/Options/LVCNext/src/cache_layout.cxx:40:6: note: in instantiation of member function 'lvcnext::CacheLayout<InterProcess::MemoryManager<InterProcess::MemoryMappedFileChar, Allocator, DynamicResize>, lvcnext::UnsynchronizedData>::Update' requested here cl.Update(cache_add_fields, cache_remove_fields, resize_list); ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/interprocess/allocators/allocator.hpp:142:4: note: candidate constructor template not viable: requires single argument 'other', but no arguments were provided allocator(const allocator<T2, SegmentManager> &other) ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/interprocess/allocators/allocator.hpp:131:4: note: *candidate constructor not viable: requires single argument 'segment_mngr', but no arguments were provided allocator(segment_manager *segment_mngr)* ^ /home/dev/build/third_party/64-rhel5/boost_1_58_0/include/boost/interprocess/allocators/allocator.hpp:136:4: note: candidate constructor not viable: requires single argument 'other', but no arguments were provided allocator(const allocator &other) ^ 1 error generated. make: *** [obj/64d-rhel6/test-rhel6.1.o] Error 1 -- View this message in context: http://boost.2283326.n4.nabble.com/Interprocess-Container-nested-containers-... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (1)
-
Malko