C++ Logo


Advanced search

Subject: Re: Rationale for return type of the non-array version of std::ssize()
From: Thiago Macieira (thiago_at_[hidden])
Date: 2020-04-29 19:56:02

On Tuesday, 28 April 2020 09:42:17 PDT Bo Persson via Std-Discussion wrote:
> Unless it is a wider type. It could be that ptrdiff_t is int and some
> container's size() function returns unsigned long long. It just *could*.

That is a distinct possibility if the container is not of objects in memory.
Examples: files in the filesystem, objects in an object store database,
database entries, etc. Or even simpler: bytes in a file.

Or on some exotic platform with small size_t and ptrdiff_t.. ptrdiff_t is not
required to work for any two arbitrary pointers, only those of one memory
block. So sizeof(uintptr_t) >= sizeof(ptrdiff_t).

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups