Chip Salzenberg on 26 Apr 2004 22:46:04 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Re: #define for 32 vs 64 bit C program?


According to Walt Mankowski:
>   printf("v has %d elements\n", v.size());
> 
> Looking through the STL documentation as well as the header files, it
> appears that size() returns a size_type, and size_type is really a
> size_t.  Is size_t guaranteed to be a long?

I should point out that if you're writing truly generic code designed
to handle any vector<>, you can't assume that type type of v.size() is
size_t, because that type is determined by the third template
parameter, the "allocator"; some user may use a non-standard allocator
which means the return type of v.size() may be different.

C++ is such a pain in the ass sometimes.
-- 
Chip Salzenberg               - a.k.a. -               <chip@pobox.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
    but he stepped in a wormhole and had to go in early."  // MST3K
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug