|
Boost Users : |
Subject: [Boost-users] [Interprocess][Container] nested containers and scoped allocators
From: Malko (malko.bravi_at_[hidden])
Date: 2015-08-13 17:17:26
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.html#container.Cpp11_conformance.scoped_allocator
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-and-scoped-allocators-tp4678830.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net