C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::unreachable<T>()

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 21 May 2026 09:02:40 -0700
On Thursday, 21 May 2026 08:58:29 Pacific Daylight Time Andrey Semashev via
Std-Proposals wrote:
> > This happens more commonly with switches over full enumerations, without
> >
> > default:
> > switch (e) {
> > case E::A: return 1;
> > case E::B: return -1;
> > }
> > Q_UNREACHABLE_RETURN(0);
>
> This still doesn't necessitate the templated std::unreachable, the
> non-template one would suffice.

If the compilers don't get fixed but we did get the templated one, I'd expect
the code to get rewritten as:

    return std::unreachable<int>();

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-05-21 16:02:47