Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #84275
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Vector - contiguous memory question. |
| Date | 2022-05-26 13:53 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <t6oeqb$igd$1@dont-email.me> (permalink) |
| References | <t6nf2c$613$1@gioia.aioe.org> |
On 5/26/22 04:51, Muttley@dastardlyhq.com wrote: > Is contiguous memory storage in a vector a recent thing or is it only > in more recent versions of C++? Ie is the following always guaranteed to > work no matter how old the compiler: > > vector<u_char> mydata; > : > fill vector > : > write(fd,&mydata[0],mydata.size()); > > or > > write(fd,mydata.data(),mydata.size()); In the original, 1998 version of the C++ standard, there was no requirement that std::vector<> be contiguous. I participated in several discussions on comp.std.c++ about that issue. Some people argued that contiguity could be inferred from other things that the standard said about std::vector<>, but those inferrences were not correct. Notably, all the reasons given for believing that std::vector<> had to be contiguous applied equally well to std::valarray<>. This is a problem, because std::valarray<> was explicitly required to be contiguous. If those arguments were valid, then they should apply to std::valarray<> too, with the result that there was no need for the standard to specify that the it was contiguous. You can find those discussions using groups.google.com and searching for contig vector My copy of C++98 is long gone, so I can't check this, but no one cited any text from the standard mandating that it be contiguous. Since I'm an inveterate standard-quoter, and was participating in that discussion, if there had been any such text, I would have quoted it. The consensus was that std::vector<> should have been required to be contiguous, and that the standard was defective by reason of failing to do so. Andrew Koenig filed DR69 <https://cplusplus.github.io/LWG/issue69>, and the proposed wording was inserted in TC1.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Vector - contiguous memory question. Muttley@dastardlyhq.com - 2022-05-26 08:51 +0000
Re: Vector - contiguous memory question. Bo Persson <bo@bo-persson.se> - 2022-05-26 11:28 +0200
Re: Vector - contiguous memory question. "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-05-26 12:36 +0200
Re: Vector - contiguous memory question. Muttley@dastardlyhq.com - 2022-05-26 16:02 +0000
Re: Vector - contiguous memory question. "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-05-26 18:25 +0200
Re: Vector - contiguous memory question. James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-05-26 13:53 -0400
Re: Vector - contiguous memory question. Vir Campestris <vir.campestris@invalid.invalid> - 2022-05-27 17:12 +0100
Re: Vector - contiguous memory question. James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-05-27 12:32 -0400
Re: Vector - contiguous memory question. Muttley@dastardlyhq.com - 2022-05-28 09:07 +0000
Re: Vector - contiguous memory question. Ben <ben.usenet@bsb.me.uk> - 2022-05-28 16:36 +0100
Re: Vector - contiguous memory question. "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-05-28 17:14 -0700
Re: Vector - contiguous memory question. Ben <ben.usenet@bsb.me.uk> - 2022-05-29 01:47 +0100
Re: Vector - contiguous memory question. "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2022-05-28 22:06 -0700
Re: Vector - contiguous memory question. Muttley@dastardlyhq.com - 2022-05-29 07:32 +0000
Re: Vector - contiguous memory question. Ben <ben.usenet@bsb.me.uk> - 2022-05-29 19:43 +0100
csiph-web