C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about the requirements of std::vector

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
cdiggins@videotron.ca
Guest





PostPosted: Fri Nov 18, 2005 12:09 am    Post subject: Question about the requirements of std::vector Reply with quote



I have been having a debate with my colleagues. They are claiming that:


"The standard specifies that &v[0] for a vector must give a
contiguous array that can be used by a function expecting
a C-style array."

I have searched the standard but I can not substantiate their claim
(and nor can they), and I believe it to be false. Can anyone point me
to where in the standard that is specified?

Thank you very much in advance,

Christopher Diggins
http://www.cdiggins.com - Home page
http://www.cpp-cookbook.com - C++ Cookbook


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Carl Barron
Guest





PostPosted: Fri Nov 18, 2005 1:04 am    Post subject: Re: Question about the requirements of std::vector Reply with quote



In article <1132247911.254285.237500 (AT) g44g2000cwa (DOT) googlegroups.com>,
<cdiggins (AT) videotron (DOT) ca> wrote:

Quote:
I have been having a debate with my colleagues. They are claiming that:


"The standard specifies that &v[0] for a vector must give a
contiguous array that can be used by a function expecting
a C-style array."

I have searched the standard but I can not substantiate their claim
(and nor can they), and I believe it to be false. Can anyone point me
to where in the standard that is specified?

Thank you very much in advance,

Christopher Diggins
http://www.cdiggins.com - Home page
http://www.cpp-cookbook.com - C++ Cookbook


it is true that the data of vector is continguous, it has been made so

by correction in the current draft of the standard [N1804=05-0064].
It was not specified in the original C++98.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
int2str@gmail.com
Guest





PostPosted: Fri Nov 18, 2005 1:04 am    Post subject: Re: Question about the requirements of std::vector Reply with quote




[email]cdiggins (AT) videotron (DOT) ca[/email] wrote:
Quote:
I have been having a debate with my colleagues. They are claiming that:

"The standard specifies that &v[0] for a vector must give a
contiguous array that can be used by a function expecting
a C-style array."

I have searched the standard but I can not substantiate their claim
(and nor can they), and I believe it to be false. Can anyone point me
to where in the standard that is specified?

23.2.4 para 1 might help:

"The elements of a vector are stored contiguously, meaning that if v is
a vector<T, Allocator> where T is some type other than bool, then it
obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
red floyd
Guest





PostPosted: Fri Nov 18, 2005 10:29 am    Post subject: Re: Question about the requirements of std::vector Reply with quote

[email]cdiggins (AT) videotron (DOT) ca[/email] wrote:
Quote:
I have been having a debate with my colleagues. They are claiming that:


"The standard specifies that &v[0] for a vector must give a
contiguous array that can be used by a function expecting
a C-style array."

I have searched the standard but I can not substantiate their claim
(and nor can they), and I believe it to be false. Can anyone point me
to where in the standard that is specified?


I believe it was corrected in TC1.

23.2.4/1:
.... "The elements of a vector are stored contiguously, meaning that if
v is a vector<T, Allocator>, where T is some type other than bool, then
it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size()."

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.