By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,162 Members | 1,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,162 IT Pros & Developers. It's quick & easy.

Custom placement for vector

P: n/a
Hi all,
In my application,I want to place a vector in a specific
location in shared memory.(a user supplied pointer).
I understand that the STL allocator mechanism places the data objects
within the STL vector in a user specified location in memory.Still the
STL container (vector) resides only within the process address space.
But I would want my STL container class(the vector skeleton as such)
as well as the data objects to be placed in shared memory. (in the same
or different segments ).
Plz tell me how to go about in this.

Thanks in Advance.

May 21 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
sr*********@gmail.com wrote:
Hi all,
In my application,I want to place a vector in a specific
location in shared memory.(a user supplied pointer).
I understand that the STL allocator mechanism places the data objects
within the STL vector in a user specified location in memory.Still the
STL container (vector) resides only within the process address space.
But I would want my STL container class(the vector skeleton as such)
as well as the data objects to be placed in shared memory. (in the same
or different segments ).
Plz tell me how to go about in this.

Thanks in Advance.


The allocator lets you control the location of the vector's dynamic
allocation. You can use placement new to control the location of the
vector proper.

Mark
May 21 '06 #2

P: n/a
In article <11**********************@j33g2000cwa.googlegroups .com>,
sr*********@gmail.com wrote:
Hi all,
In my application,I want to place a vector in a specific
location in shared memory.(a user supplied pointer).
I understand that the STL allocator mechanism places the data objects
within the STL vector in a user specified location in memory.Still the
STL container (vector) resides only within the process address space.
But I would want my STL container class(the vector skeleton as such)
as well as the data objects to be placed in shared memory. (in the same
or different segments ).
Plz tell me how to go about in this.


I would say don't do it. Instead use a c_array like class, for example
the one in "The C++ Programming Language".
May 21 '06 #3

P: n/a

Mark P wrote:
sr*********@gmail.com wrote:
Hi all,
In my application,I want to place a vector in a specific
location in shared memory.(a user supplied pointer).
I understand that the STL allocator mechanism places the data objects
within the STL vector in a user specified location in memory.Still the
STL container (vector) resides only within the process address space.
But I would want my STL container class(the vector skeleton as such)
as well as the data objects to be placed in shared memory. (in the same
or different segments ).
Plz tell me how to go about in this.

Thanks in Advance.


The allocator lets you control the location of the vector's dynamic
allocation. You can use placement new to control the location of the
vector proper.

Mark


Mark,
Plz tell me how to use placement new for a vector .
The implementation of a vector might use placement new by
itself.
How can I override the existing placement new for a vector?

May 21 '06 #4

P: n/a
* sr*********@gmail.com:
Mark P wrote:
sr*********@gmail.com wrote:
Hi all,
In my application,I want to place a vector in a specific
location in shared memory.(a user supplied pointer).
I understand that the STL allocator mechanism places the data objects
within the STL vector in a user specified location in memory.Still the
STL container (vector) resides only within the process address space.
But I would want my STL container class(the vector skeleton as such)
as well as the data objects to be placed in shared memory. (in the same
or different segments ).
Plz tell me how to go about in this.

Thanks in Advance.

The allocator lets you control the location of the vector's dynamic
allocation. You can use placement new to control the location of the
vector proper.

Mark


Mark,
Plz tell me how to use placement new for a vector .
The implementation of a vector might use placement new by
itself.
How can I override the existing placement new for a vector?


A std::vector object contains at least one pointer to an internal buffer.

To make the vector work in shared memory you'd have to (1) make sure
that the vector's internal buffer is allocated from some shared memory
region A, and (2) make sure that region A has the same logical start
address in all processes accessing the vector.

Since it's highly unlikely that you'll be able to do that, and since you
have no guarantee that there aren't any other pointers, you're almost
guaranteed to fail in this approach.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
May 21 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.