GCC vector element access pointers in C++

Marius Miknis marius.miknis@southwales.ac.uk
Tue Jan 26 09:13:00 GMT 2016


Hi Marc,

Thanks for such a quick reply, I appreciate it. 

Yes I am trying to speed up my testing in debug as working with point clouds of +600,000 points stored in vectors is really really slow, thus using _ MyFirst and _MyLast removes all the dereferencing/accessing overheads as I work directly with pointers and can just increment pointer addresses, plus even if the vector gets resized _ MyFirst and _MyLast are not affected.

I did look through the stl_vector.h but it sadly seems that I can not use ._M_impl._M_start. I am aware that compiler will remove all the overheads in release but currently in debugging I need a fast way to access and move through the vector.

Kind Regards,
Marius

-----Original Message-----
From: Marc Glisse [mailto:marc.glisse@inria.fr] 
Sent: 26 January 2016 09:06
To: Marius Miknis <marius.miknis@southwales.ac.uk>
Cc: gcc-help@gcc.gnu.org
Subject: Re: GCC vector element access pointers in C++

On Tue, 26 Jan 2016, Marius Miknis wrote:

> Hello,
>
> I do apologise if this might be wrong email to pose such a question.
>
> I wanted to ask what is the GCC C++ equivalent implementation of Windows _ MyFirst and _MyLast vector pointers?
> These give direct access to the vectors first and last element, but they ar e not present in the GCC implementation of the vector class.

The best thing you can do is read the source. From the file vector, you can see that you need to read the file bits/stl_vector.h. And there you will find 2 private members that you cannot use anyway. Or is this for use in a debugger?

--
Marc Glisse



More information about the Gcc-help mailing list