Re: [ROOT] Performance of Streamers -- code generated for STL vectors.

From: Walter F.J. Mueller (w.f.j.mueller@gsi.de)
Date: Mon Dec 03 2001 - 21:47:30 MET


Rene Brun wrote:
> I understand that you may gain time in making this storage assumption.

The original STL standard left the question "Must elements of a vector be
contiguous?" indeed open. This issue comes up quickly whenever a STL vector
is to be interfaced with other code, see for example discussion on
Josuttis book on the STL, section 6.2.3 page 155. 

Finally the C++ Library Working Group issued a clear statement:

  The issue is this: 
     Must the elements of a vector be in contiguous memory?

  Proposed resolution:
     Add the following text to the end of 23.2.4 [lib.vector], paragraph 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().

The above statement has been issues as a `defect report' to the STL spec, see

   http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#69

> However, this is not guaranteed to work on all compilers or with the
> next version of the same compiler.

If current compiler versions work, future versions will too because the STL
spec is clearly moving in this direction.

> If you want to gain time, use TClonesArray instead.

In my case I had to handle a few varying size arrays of elementary types.
It's hard to see how that can be done with TClonesArray.


			Cheers,		Walter

--
Walter F.J. Mueller   Mail:  W.F.J.Mueller@gsi.de
GSI,  Abteilung KP3   Phone: +49-6159-71-2766
D-64291 Darmstadt     FAX:   +49-6159-71-2989
WWW:   http://www-kp3.gsi.de/www/kp3/people/mueller.html
PGP:   http://www-kp3.gsi.de/~mueller/pgp.shtml



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET