468,735 Members | 2,131 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,735 developers. It's quick & easy.

Custom placement for vector

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
4 2297
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
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

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
* 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.

Similar topics

11 posts views Thread by Peter Olcott | last post: by
15 posts views Thread by Alex Vinokur | last post: by
8 posts views Thread by elviin | last post: by
15 posts views Thread by natespamacct | last post: by
1 post views Thread by SarahT | last post: by
9 posts views Thread by karthikbalaguru | last post: by
11 posts views Thread by letz | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.