C++ Logo

sg16

Advanced search

Re: [isocpp-sg16] Thoughts on P4235R0: Removing Digraphs

From: Hubert Tong <hubert.reinterpretcast_at_[hidden]>
Date: Tue, 6 Oct 2026 20:42:50 -0400
On Tue, Oct 6, 2026 at 6:43 PM Alisdair Meredith <alisdairm_at_[hidden]> wrote:

> I remember the distinction between trigraphs and digraphs now.
>
> Trigraphs were processed at a per-character level, essentially a form of
> character
> encoding in source. When trigraphs were removed, IBM are able to continue
> honoring trigraphs with their original meaning by making them part of the
> phase 1
> source-to-basic-character-set mapping.
>
> Digraphs work at the token level, so are *not* appropriate for handling as
> part of
> the character mapping in phase 1. This shows up in things like string
> literals. Note
> that the old rules for backing out trigraph expansion in raw string
> literals no longer
> easily apply in the IBM case, but they seemed ready to accept that as long
> that they
> can portably pragma the code page. Hubert might well correct me on
> “accept” though ;)
>

We still back them out in raw string literals. The world has not changed
enough that simply enabling trigraphs is causing any issues yet.
As mentioned elsewhere in the thread, the "encoding" is allowed to be C++
tokenization-aware :)

There probably will come a time when we will need to turn off trigraphs
(but still allow usage of ??= in place of # for introducing a preprocessor
directive).
That time will probably come when some frequently re-built open source
project won't accept "?\?!" in place of "??!" in some precious string
literal.

-- HT

Received on 2026-10-07 00:43:21