473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing to Vector Buffer

I have read some posts mentioning reading from a STL vector's buffer by
using &vec.front(), but I haven't seen anything regarding writing to
the vector using its buffer. I am using MPI to send some vectors
around; is it ok to receive data using a vector's buffer? e.g.:

vector<int> src(75);
MPI_Send(&src.front(), 75, ...)
-----------------------
vector<int> dest(100);
MPI_Recv(&dest.front(), 100, ...);

Presumably, this would send all 75 ints in src to the first 75
locations in dest. Or would it?

Scott

May 10 '06 #1
2 5474
Scott Kilpatrick wrote:
I have read some posts mentioning reading from a STL vector's buffer by
using &vec.front(), but I haven't seen anything regarding writing to
the vector using its buffer. I am using MPI to send some vectors
around; is it ok to receive data using a vector's buffer? e.g.:

vector<int> src(75);
MPI_Send(&src.front(), 75, ...)
-----------------------
vector<int> dest(100);
MPI_Recv(&dest.front(), 100, ...);

Presumably, this would send all 75 ints in src to the first 75
locations in dest. Or would it?


You'll want to post in a group related to MPI since it is off-topic
here. I can confirm that std::vectors store their values in contiguous
memory blocks and are intended to interoperate well with C APIs. The
usual idiom I use is &vec[0], however.

Cheers! --M

May 10 '06 #2
mlimber wrote:
You'll want to post in a group related to MPI since it is off-topic
here. I can confirm that std::vectors store their values in contiguous
memory blocks and are intended to interoperate well with C APIs. The
usual idiom I use is &vec[0], however.


Thanks for the quick reply. I assumed that the functionality would be
irrelevant to MPI itself, but I will ask there to make sure.

Thanks again,
Scott

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII...
5
by: {AGUT2} {H}-IWIK | last post by:
Hi, I'm trying to pass my vector to a function external to my main(), but my compiler is complaining. FYI, the struct for the facetInfo works perfectly, it's just the vector passing. A quick...
4
by: Koen De Wolf | last post by:
Dear all, I created a 2 dimensional vector structure that contains some integer values. The dimensions are dynamic. When I want to add values to it, using , I always get an "Access violation"...
3
by: jitu.csewizard | last post by:
hi overview: function sprintf(<buffername>,<format string>, .....) in this function you need to allocate the size of buffername before hand. question: function ssprintf(<buffername>,<format...
6
by: Wes | last post by:
I'm running FreeBSD 6.1 RELEASE #2. The program is writting in C++. The idea of the program is to open one file as input, read bytes from it, do some bitwise operations on the bytes, and then...
6
by: paul.anderson | last post by:
This code doesn't work - the first retrieval of t2 returns valid data, the subsequent do not. Please help!!! int main(int argc, char* argc){ struct Test{ int i; int j; intk; int l; }
7
by: JH Programmer | last post by:
Hi, is there any ways that allow us to delete an element in between? say int_val: 1 int_val: 2 int_val: 3
1
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like...
3
by: jason.cipriani | last post by:
I'm in a rather strange situation. I have a class that does some stuff and uses a buffer to hold some data in; the details aren't important but the buffer is an std::vector: class Something {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.