Re: How to encode STL vector
Re: How to encode STL vector
- Subject: Re: How to encode STL vector
- From: "Clark S. Cox III" <email@hidden>
- Date: Thu, 7 Nov 2002 08:17:01 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday, Nov 7, 2002, at 00:50 US/Eastern, Dan Crevier wrote:
On 11/6/02 5:14 AM, "Clark S. Cox III" <email@hidden> wrote:
On Wednesday, Nov 6, 2002, at 04:46 US/Eastern, Arthur Clemens wrote:
I was wondering how to encode a vector type using NSCoding?
I have a vector of unsigned ints.
You can encode it just like you would a plain C array:
//Encode
const unsigned size = myVector.size();
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &size];
[aCoder encodeArrayOfObjCType: @encode(unsigned) count: size at:
&myVector.front()];
I think you want &myVector[0] instead of &myVector.front(). Using
front()
assumes that the iterators for vectors are simple pointers.
No, front() has nothing to do with iterators, it returns a reference
(not a pointer or an iterator) to the first element of the vector (it's
begin() that returns an iterator).
- --
http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)
iEYEARECAAYFAj3KZ9IACgkQd6STocYT1xVMbwCeLWsBdTT5C2wh8DQnoNSa709E
uJgAnjBOUpTuNoxCB+Y03asVK0ht2TT8
=1cVg
-----END PGP SIGNATURE-----
_______________________________________________
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.