define max length for allocator

This is a discussion on define max length for allocator within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, In MSDN length_error sample, http://msdn2.microsoft.com/en-us/library/2af6btx2.aspx it uses internal macro _SIZT, other than size_t. I have found in file ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    define max length for allocator

    Hello everyone,


    In MSDN length_error sample,

    http://msdn2.microsoft.com/en-us/library/2af6btx2.aspx

    it uses internal macro _SIZT, other than size_t. I have found in file xmemory, _SIZT is defined to size_t.

    So, my questions are

    1. why not use size_t directly, why use an internal name (begins with _)?

    2. Do we have to use _SIZT when we define a customized allocator?


    thanks in advance,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I'd put it down to lack of concentration on the part of the programmer who wrote the example.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks CornedBee,


    Sorry English is not my native language. I do not quite understand your points. Could you coment on my original 2 questions please? :-)

    Quote Originally Posted by CornedBee View Post
    I'd put it down to lack of concentration on the part of the programmer who wrote the example.

    regards,
    George

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,301
    _SIZT is a vendor/implementation specific macro. To answer your points;

    1) Microsoft engineers would have used it just in case implementation details of their compiler/library change so an allocator no longer works with size_t. IMHO, this is just unnecessary future-proofing: size_t is unlikely to disappear from standards in the foreseeable future.

    2) No. For custom allocators, use whatever data types or structures are required so your allocator can manage memory as required. There is no obligation to use _SIZT, just as there is no obligation to use size_t. As a rule of thumb, however, it is better to code something portably unless you have a specific reason not to. So it's better to use standardised language features (eg size_t) rather than vendor-specific ones (_SIZT).

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks grumpy,


    Question answered.

    Quote Originally Posted by grumpy View Post
    _SIZT is a vendor/implementation specific macro. To answer your points;

    1) Microsoft engineers would have used it just in case implementation details of their compiler/library change so an allocator no longer works with size_t. IMHO, this is just unnecessary future-proofing: size_t is unlikely to disappear from standards in the foreseeable future.

    2) No. For custom allocators, use whatever data types or structures are required so your allocator can manage memory as required. There is no obligation to use _SIZT, just as there is no obligation to use size_t. As a rule of thumb, however, it is better to code something portably unless you have a specific reason not to. So it's better to use standardised language features (eg size_t) rather than vendor-specific ones (_SIZT).

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 03:13 PM
  3. Help getting multiple keypresses in a DOS compiler
    By Nongan in forum Game Programming
    Replies: 2
    Last Post: 04-01-2005, 09:07 PM
  4. float toolbar!
    By c-- in forum Windows Programming
    Replies: 5
    Last Post: 02-04-2003, 08:44 AM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 03:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21