• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to encode STL vector
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to encode STL vector


  • Subject: Re: How to encode STL vector
  • From: Dan Crevier <email@hidden>
  • Date: Wed, 06 Nov 2002 23:02:44 -0800

On 11/6/02 7:38 PM, "James Montgomerie" <email@hidden> wrote:

> Note, however, that though in all the implementations I know of,
> &myVector.front() does return an pointer to the Vector's internal
> array, I don't believe it's guaranteed to by the standard. I think
> that a Vector can use any O(1) storage, and if it did (or changed to in
> the future) use something other than a plain array, your code would
> break (because, for example, the second item is not guaranteed to be
> adjacent in memory to the first).

Actually, the standard does guarantee that it's contiguous in memory, but
you aren't guaranteed that the iterator is a simple pointer. For example,
Metrowerk's vector implementation does not use a simple pointer in the
latest version. That's you need to use &myVector[0]. See Scott Myer's More
Effective STL for more info. It's a great book.

Dan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: How to encode STL vector (From: James Montgomerie <email@hidden>)

  • Prev by Date: Re: How to encode STL vector
  • Next by Date: Re: To all cocoa developers - new cocoa dev forum
  • Previous by thread: Re: How to encode STL vector
  • Next by thread: Re: How to encode STL vector
  • Index(es):
    • Date
    • Thread