C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: size_type of standard containers

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Mirek Fidler
Guest





PostPosted: Thu Jul 10, 2003 4:15 pm    Post subject: Re: size_type of standard containers Reply with quote



Quote:
According to the standard, std::vector<X>::size_type is required to
be
std::size_t. For all types T (except maybe bool).

Oh, yes. The weasel rules in 20.1.5/4 Smile

If that is true then it might have negative performance impact on
e.g. AMD64 platform - as all indices will be stored as 64-bit values
(that is what I expect size_t to be), while native int size is 32-bits.

Mirek


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
David Abrahams
Guest





PostPosted: Sat Jul 12, 2003 7:45 pm    Post subject: Re: size_type of standard containers Reply with quote



[email]cxl (AT) volny (DOT) cz[/email] ("Mirek Fidler") writes:

Quote:
According to the standard, std::vector<X>::size_type is required
to be std::size_t. For all types T (except maybe bool).

Oh, yes. The weasel rules in 20.1.5/4 :-)

If that is true then it might have negative performance impact on
e.g. AMD64 platform - as all indices will be stored as 64-bit values
(that is what I expect size_t to be), while native int size is 32-bits.


It isn't true. A conforming library implementation is permitted to
assume that size_type is size_t, but it is also allowed to be smarter
and allow for different size_type's.

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Bo Persson
Guest





PostPosted: Mon Jul 14, 2003 9:56 pm    Post subject: Re: size_type of standard containers Reply with quote




""Mirek Fidler"" <cxl (AT) volny (DOT) cz> skrev i meddelandet
news:bej7m0$5edj2$1 (AT) ID-198693 (DOT) news.dfncis.de...
Quote:
According to the standard, std::vector<X>::size_type is required
to
be
std::size_t. For all types T (except maybe bool).

Oh, yes. The weasel rules in 20.1.5/4 :-)

If that is true then it might have negative performance impact
on
e.g. AMD64 platform - as all indices will be stored as 64-bit values
(that is what I expect size_t to be), while native int size is
32-bits.


Or not...

Quote:
From what I have seen, compilers like MSVC and gcc seems to keep int
and long at 32 bits, even though a pointer is 64 bits. How is this

solved for the standard library?



Bo Persson
[email]bop2 (AT) telia (DOT) com[/email]

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Ben Hutchings
Guest





PostPosted: Wed Jul 16, 2003 9:28 pm    Post subject: Re: size_type of standard containers Reply with quote

In article <RZ_Pa.16087$mU6.15403 (AT) newsb (DOT) telia.net>, "Bo Persson" wrote:
Quote:

""Mirek Fidler"" <cxl (AT) volny (DOT) cz> skrev i meddelandet
news:bej7m0$5edj2$1 (AT) ID-198693 (DOT) news.dfncis.de...
According to the standard, std::vector<X>::size_type is required
to be std::size_t. For all types T (except maybe bool).

Oh, yes. The weasel rules in 20.1.5/4 :-)

If that is true then it might have negative performance impact
on e.g. AMD64 platform - as all indices will be stored as 64-bit
values (that is what I expect size_t to be), while native int size
is 32-bits.

Or not...

From what I have seen, compilers like MSVC and gcc seems to keep int
and long at 32 bits, even though a pointer is 64 bits. How is this
solved for the standard library?

GCC doesn't do this; for 64-bit architectures it uses 32-bit ints and
64-bit longs. VC++ behaves as you say. It doesn't even support C99's
long long! Instead it has non-standard types called (signed|unsigned)
__int64 and uses these to define size_t and ptrdiff_t for 64-bit
architectures.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Bo Persson
Guest





PostPosted: Thu Jul 17, 2003 4:38 pm    Post subject: Re: size_type of standard containers Reply with quote


"Ben Hutchings" <do-not-spam-benh (AT) bwsint (DOT) com> skrev i meddelandet
news:slrnbhamo5.1dc.do-not-spam-benh (AT) tin (DOT) bwsint.com...
Quote:
In article <RZ_Pa.16087$mU6.15403 (AT) newsb (DOT) telia.net>, "Bo Persson"
wrote:

""Mirek Fidler"" <cxl (AT) volny (DOT) cz> skrev i meddelandet
news:bej7m0$5edj2$1 (AT) ID-198693 (DOT) news.dfncis.de...
According to the standard, std::vector<X>::size_type is
required
to be std::size_t. For all types T (except maybe bool).

Oh, yes. The weasel rules in 20.1.5/4 :-)

If that is true then it might have negative performance
impact
on e.g. AMD64 platform - as all indices will be stored as 64-bit
values (that is what I expect size_t to be), while native int
size
is 32-bits.

Or not...

From what I have seen, compilers like MSVC and gcc seems to keep
int
and long at 32 bits, even though a pointer is 64 bits. How is this
solved for the standard library?

GCC doesn't do this; for 64-bit architectures it uses 32-bit ints
and
64-bit longs.

ok.

Quote:
VC++ behaves as you say. It doesn't even support C99's
long long! Instead it has non-standard types called
(signed|unsigned)
__int64 and uses these to define size_t and ptrdiff_t for 64-bit
architectures.

Well, in version 7.1 it actually has a long long (as a synonym for its
own __int64). I was more curious on how the C++ standard addresses
compilers were pointers are longer than all of the int types. Using a
C99 type seems like cheating! :-)


Bo Persson
[email]bop2 (AT) telia (DOT) com[/email]

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
James Kuyper
Guest





PostPosted: Fri Jul 18, 2003 10:34 pm    Post subject: Re: size_type of standard containers Reply with quote

[email]do-not-spam-benh (AT) bwsint (DOT) com[/email] (Ben Hutchings) wrote in message news:<slrnbhdt3k.1ik.do-not-spam-benh (AT) tin (DOT) bwsint.com>...
....
Quote:
I was more curious on how the C++ standard addresses
compilers were pointers are longer than all of the int types. Using a
C99 type seems like cheating! :-)

There's nothing inherently wrong with that. However, for implementations
with a flat memory model it makes sense for ptrdiff_t and size_t to be
the same size as pointers, and I think those types are required to be
typedefs for standard integer types.

The C++ standard doesn't specify that directly, apparantly deferring
that issue to the C standard. The current C++ standard
cross-references the C90 standard, and I don't have a copy of that. I
do, however, have a copy of the C99 standard, which specifies that
ptrdiff_t must be a signed integer type, and that size_t must be an
unsigned integer type. In C99, the signed integer types are explicity
defined as including both standard integer types and extended
(implementation-defined) integer types.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Ross Ridge
Guest





PostPosted: Sat Jul 19, 2003 7:36 pm    Post subject: Re: size_type of standard containers Reply with quote

James Kuyper <kuyper (AT) wizard (DOT) net> wrote:
Quote:
The C++ standard doesn't specify that directly, apparantly deferring
that issue to the C standard. The current C++ standard
cross-references the C90 standard, and I don't have a copy of that. I
do, however, have a copy of the C99 standard, which specifies that
ptrdiff_t must be a signed integer type, and that size_t must be an
unsigned integer type. In C99, the signed integer types are explicity
defined as including both standard integer types and extended
(implementation-defined) integer types.

I don't have the C90 standard handy either, but I'm pretty sure that's
new for C99. I remember POSIX having a similiar issue because it said
some types were arithmetic types and deferred to the C90 standard for
the definition of what an arithmetic type was.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] [email]rridge (AT) csclub (DOT) uwaterloo.ca[/email]
-()-/()/ http://www.csclub.uwaterloo.ca/u/rridge/
db //

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.