Topic: What is a size_t


Author: Bret Pehrson <bretp@strata3d.com>
Date: 1997/03/25
Raw View
I just scanned CD2, and I can't find what a size_t is supposed to be:
  unsigned int
  unsigned long

???

Also, while I'm on it, why do intrinsic language elements require the
use of headers?  For example, operator new takes size_t as its
size.  Why not make either: size_t a builtin type or operator new
take an unsigned int?

--
Bret Pehrson        mailto:BretP@strata3d.com
*Please post all questions to newsgroup
*Please carbon-copy all responses to newsgroup
--
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Stephen.Clamage@eng.sun.com (Steve Clamage)
Date: 1997/03/25
Raw View
In article 3763@strata3d.com, Bret Pehrson <bretp@strata3d.com> writes:
>I just scanned CD2, and I can't find what a size_t is supposed to be:
>  unsigned int
>  unsigned long
>
>???

Take a look at 18.1 "Types", and you will see that size_t is defined
in <stddef.h> and has the same requirements as in C. It is the type
returned by the operator sizeof, and is an implementation-defined
unsigned integral type. (That part of the C standard is included
by explicit reference.)

>Also, while I'm on it, why do intrinsic language elements require the
>use of headers?  For example, operator new takes size_t as its
>size.  Why not make either: size_t a builtin type or operator new
>take an unsigned int?

Size_t is inherited from C, where it is defined in a standard header.
There did not seem to be any great advantage in making it a built-in type,
and the disadvantage would be adding an unnecessary incompatibility
with C.

You could make the argument (and I have done so) that all standard
headers should be abolished (made no-ops for compatibility) and C++ should
simply predefine and reserve the entire standard library. If we don't
take that route, it seems most sensible to make only those changes
whose benefits greatly outweigh their disadvantages.

---
Steve Clamage, stephen.clamage@eng.sun.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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]