Slides for P3666R4
Bit-precise integers

Document number:
P4157R1
Date:
2026-06-11
Audience:
LEWG
Project:
ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21
Reply-To:
Jan Schultke <janschultke@gmail.com>
Source:
github.com/Eisenwave/cpp-proposals/blob/master/src/bitint-lewg-slides.cow

This document has custom controls:

  • ,  ↓ : go to the next slide
  • ,  ↑ : go to previous slide

Bit-precise integers
P3666R4

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 1

Introduction

C23 now has _BitInt type for N-bit integers (WG14 N2763, N2775):

// 8-bit unsigned integer initialized with value 255. // The literal suffix wb is unnecessary in this case. unsigned _BitInt(8) x = 0xFFwb;
Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 2

P3666R3 LEWG in Croydon 2026

POLL: We should prevent library support for _BitInt
SFFNASA
59231
Outcome: Consensus in favor
POLL: std::is_integral_v<_BitInt(N)> should be false
SFFNASA
74520
Outcome: Consensus in favor
POLL: We should provide alias templates for _BitInt […]
SFFNASA
03835
Outcome: Consensus against
POLL: We should provide std::bit_int and std::bit_uint as class templates […]
SFFNASA
24840
Outcome: No consensus
Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 3

std::is_integral_v<_BitInt(N)>

POLL: std::is_integral_v<_BitInt(N)> should be false

SFFNASA
74520

Outcome: Consensus in favor

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 4

Intuition

A bit-precise integer is an integer.

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 5

Procedural issues

Two schools of thought

  1. The type trait simply reports what is an integer type in the core language.
    • LEWG has no design freedom; EWG decides
    • poll outcome is procedurally invalid
  2. The type trait is observable behavior, anything else is wording strategy.
    • LEWG gets to decide
    • integer type can be redefined if use sites are updated
    • e.g. std::is_class_v is false for unions (but unions are class types)
Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 6

P3666R4 type taxonomy — C compatibility

integral types
   ├── signed or unsigned integer types
   │   ├── standard integers: int, unsigned, etc.
   │   ├── extended integers: __int128 etc.
   │   └── bit-precise integers: (unsigned) _BitInt(N)
   ├── character types: char, wchar_t, etc.
   └── bool
Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 7

std::is_integral is underconstraining

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 8

std::is_integral_v<_BitInt(N)>
is already true in libc++

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 9

Most code handles the change fine

template<std::integral T> T mul(T x, T y) { return x * y; }
Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 10

Extended integer types

Key question:

If the implementation can arbitrarily extend integral type, why can't we extend it with _BitInt?

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 11

std::is_integral_v<_BitInt(N)>
is eternal

Key question:

If std::is_integral_v<_BitInt(N)> is false now, can we suddenly make it true later?

Likely answer:

This is our only chance to make it true.

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 12

Extending categories of fundamental types

Past:

Future:

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 13

The end

Jan Schultke  |  LEWG Slides for P3666R4 — Bit-precise integers  |  Brno 2026  |  Slide 14