Thursday, December 10, 2015

Digest for comp.lang.c++@googlegroups.com - 1 update in 1 topic

Paavo Helde <myfirstname@osa.pri.ee>: Dec 10 05:07PM -0600

Christian Gollwitzer <auriocus@gmx.de> wrote in news:n4cuv7$is9$1@dont-
email.me:
 
> Am 10.12.15 um 16:53 schrieb David Brown:
>> On 10/12/15 14:49, Alf P. Steinbach wrote:
>>> Due to its backward compatibility with C, from the 1970s, C++'s set
of
>>> built-in types is not ideally suited for modern programming as of
2015.
 
>>> • No standard signed size type (Posix has ssize_t).
 
>> Why would you need a signed size type? Posix uses it for some IO
>> functions, in order to return a value that is either a positive count
of
>> bytes on success, or a negative error value on failure. If you are
>> using these functions, you are using Posix and have ssize_t. If you
are
>> using C++, you might want to use exceptions for your errors rather
than
>> "negative size".
 
> What would be the correct type for an index, which can be negative? I
am
 
> What is the correct data type for the indices?
 
> int: not capable of holding every index on 64bit platforms
> long: not capable of holding the index on WIndows64, where long is 32
bit
> ssize_t: not standard C++
 
> intptr_t:
> ptrdiff_t: both seem correct, apart from the name
 
A typedef to the needed type. If you need to process huge arrays of
indices and the indices themselves will not exceed 2^31 then int32_t,
otherwise int64_t (32-bit platforms are something in the past, aren't
they?).
 
hth
Paavo
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: