Title
"Basic integral types" should not be used
Status
new
Section
[stream.types]
Submitter
Jiang An

Created on 2022-05-07.00:00:00 last changed 2 weeks ago

Messages

Date: 2025-06-16.11:24:24

Proposed resolution:

This wording is relative to N5008.

  1. Modify [stream.types] as indicated:

    using streamoff = implementation-defined;

    -1- The type `streamoff` is a synonym for one of the signed basic integral types of sufficient size to represent the maximum possible file size for the operating system.256

    using streamsize = implementation-defined;

    -2- The type `streamsize` is a synonym for one of the signed basic integral types. It is used to represent the number of characters transferred in an I/O operation, or the size of I/O buffers.257

    256) Typically `long long`.

    257) Most places where `streamsize` is used would use `size_t` in C, or `ssize_t` in POSIX.

Date: 2025-06-15.00:00:00

[ 2025-06-16; Jonathan adds wording ]

Date: 2022-05-15.00:00:00

[ 2022-05-17; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2022-05-07.00:00:00

Raised from editorial issue #5240.

The phrase "signed basic integral types" in [stream.types] has been present since C++98 but never defined. It is unclear whether "basic integral types" are "standard integer types" or "integer types" (including extended integer types).

As std::streamoff should be wide enough to represent the largest possible file size, and std::uintmax_t is used as the return type of std::filesystem::file_size, we should not disallow std::streamoff to be an extended integer type which may be wider than long long. On the other hand, as std::size_t and std::ptrdiff_t have already been allowed to be extended integer types, std::streamsize should also be allowed to be an extended integer type for consistency.

So I think we should just use "signed integer types" instead of "signed basic integral types" in [stream.types].

History
Date User Action Args
2025-06-16 11:24:24adminsetmessages: + msg14833
2025-06-16 11:24:24adminsetmessages: + msg14832
2022-05-17 11:58:16adminsetmessages: + msg12467
2022-05-07 00:00:00admincreate