Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #13358
| From | "Paul" <pchrist<nospam>or@yahoo.co.uk> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: How to free this memory? |
| Date | 2012-01-13 20:35 +0000 |
| Organization | Netfront http://www.netfront.net/ |
| Message-ID | <jeq4jj$1k4a$1@adenine.netfront.net> (permalink) |
| References | <CB35C06F.B997%bint@ign.com> <jepq5f$bvj$1@dont-email.me> <jepru7$1887$1@adenine.netfront.net> <jeptmu$2v8$1@dont-email.me> |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> wrote in message news:jeptmu$2v8$1@dont-email.me... > On 13.01.2012 19:07, Paul <pchrist wrote: >> >> How would you extract a pointer from the vector? > > You can just take the address of an element, like > > &v[0] > > or > > &front() > > for a non-empty vector v. > > The vector buffer has been guaranteed contiguous since C++03. > > With C++11 there is also a data() member function that has both const and > non-const version, and that gives you &front() directly. > > > Cheers & hth., > > - Alf Also i reply to Kevins post... I see the vector <bool> inconsistency and try to avoid vector<bool>. But I still feel uncomfortable taking the address of a vector element. There seems to be some dark looming uncomfortable danger attached to this, I just can't put my finger on it. I can see no harm on a single thread application however I wonder if there may be implications on MT apps. For example if one thread has a pointer and a different thread has modified the vector, in such a way that the pointer is invalidated. What I am getting at is, even with STL containers, programmers still need to tread carefully. In some appications, or programs, the STL container is the perfect solution. but I don't think this is always the case. I believe there is still a large userbase who require the raw memory managment features of C++. STL allocators are a very usefull, not to mention productive, feature of C++ but they are an abstract feature. The basic laguage does not restrict its useage to this abstract feature and for this we should be thankfull. C++ is a powerfull programming language because it has so many different features, we can use C++ as a Java like language(high level), or as a C like language(low level) it has many different features and I think this is an important aspect of its success. I think the STL part of the C++ language is just one aspect of its many uses and should not be emphasised to be any more important that the other aspects. It woud be great if in the future we had one common programming language , based on binary. But lets wait and see what happens with quantumn computers, maybe binary is a bit retarded and we need to start thiking in 3's, who knows. Actually quantum is all about two's( the atom is either in the box or not in the box) so maybe our knowledge of binary and quantumn fit together well. --- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to free this memory? Bint <bint@ign.com> - 2012-01-13 11:05 -0600
Re: How to free this memory? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-01-13 18:37 +0100
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 18:07 +0000
Re: How to free this memory? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-01-13 19:38 +0100
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 20:35 +0000
Re: How to free this memory? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-14 02:16 -0800
Re: How to free this memory? Kevin McCarty <kmccarty@gmail.com> - 2012-01-16 09:08 -0800
Re: How to free this memory? Kevin McCarty <kmccarty@gmail.com> - 2012-01-13 10:48 -0800
Re: How to free this memory? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-14 02:19 -0800
Re: How to free this memory? Kevin McCarty <kmccarty@gmail.com> - 2012-01-16 08:56 -0800
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 18:16 +0000
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 17:37 +0000
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 17:47 +0000
Re: How to free this memory? Bint <bint@ign.com> - 2012-01-13 12:04 -0600
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 18:10 +0000
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 19:20 +0000
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 19:27 +0000
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 19:52 +0000
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 20:33 +0000
Re: How to free this memory? "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2012-01-13 20:52 +0000
Re: How to free this memory? David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-13 15:01 -0600
Re: How to free this memory? BCFD36 <bcfd36@cruzio.com> - 2012-01-14 02:01 -0800
Re: How to free this memory? "MikeWhy" <boat042-nospam@yahoo.com> - 2012-01-13 15:46 -0600
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-13 21:59 +0000
Re: How to free this memory? Goran <goran.pusic@gmail.com> - 2012-01-13 22:12 -0800
Re: How to free this memory? Leigh Johnston <leigh@i42.co.uk> - 2012-01-14 11:58 +0000
Re: How to free this memory? Goran <goran.pusic@gmail.com> - 2012-01-13 22:01 -0800
Re: How to free this memory? Victor Bazarov <v.bazarov@comcast.invalid> - 2012-01-13 13:48 -0500
Re: How to free this memory? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-01-14 20:46 +0000
Re: How to free this memory? Bint <bint@ign.com> - 2012-01-13 11:54 -0600
Re: How to free this memory? Travis Vitek <travis.vitek@gmail.com> - 2012-01-13 09:21 -0800
Re: How to free this memory? jgk@panix.com (Joe keane) - 2012-01-14 01:03 +0000
csiph-web