are there c++ updates?

Started by
25 comments, last by wolfbane 20 years, 1 month ago
quote:Original post by Beer Hunter
Most importantly, are std::vectors contiguous now?

Sure.

Has there ever been an implementation which was non-contiguous?
Advertisement
quote:Has there ever been an implementation which was non-contiguous?

No.

[edited by - noVum on March 6, 2004 9:21:06 AM]
quote:Original post by Trap
quote:Original post by Beer Hunter
Most importantly, are std::vectors contiguous now?

Sure.

Has there ever been an implementation which was non-contiguous?


Yes, there has been. I wrote one myself to demonstrate that it could be done and still be compliant with respect to the original standard.

Anyways, TC1 adds this sentence to the end of paragraph 1 in 23.2.4: "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()."
I know that one can write such a vector. There even is a paper which suggest a non-contiguous vector-type: "Resizable Arrays in Optimal Time and Space".

But i believe no c++-compiler was ever distributed with such a non-contiguous vector.
quote:Original post by SiCrane
792 pages of technical minutia and language lawyer babble. I have a hard copy sitting next to my keyboard. The British Standards Institute through Wiley publishers, has put it out in book form for about $65 US.


The Wiley hardcover includes TC1? Hmmm... time to place an order.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
quote:Original post by Fruny
quote:Original post by SiCrane
792 pages of technical minutia and language lawyer babble. I have a hard copy sitting next to my keyboard. The British Standards Institute through Wiley publishers, has put it out in book form for about $65 US.


The Wiley hardcover includes TC1? Hmmm... time to place an order.


Yup, it''s even part of the title if you look it up on Amazon.
quote:Original post by Trap
But i believe no c++-compiler was ever distributed with such a non-contiguous vector.

You might still be wrong on a technicality. There was one SOB of a professor at UIUC who used this horrible, evil compiler from hell for machine problems. Basically it did everything in inefficient, counter-intuitive ways to enforce good coding standards or things would die horribly. vptrs in classes were xor''ed with their address so that memcpy''ing a class object would segfault the program, the vector class was non-contiguous, internal object layout was done in the most convoluted manner possible, even the most trivial of heap buffer overruns would corrupt the heap, etc. (Admittedly, he retired my freshman year, and I never took any of his courses, so this could have just been a horrible myth spread by the TAs to scare the undergrads.)

This topic is closed to new replies.

Advertisement