Date: Thu, 21 May 2026 18:58:29 +0300
On 21 May 2026 18:34, Thiago Macieira via Std-Proposals wrote:
> On Thursday, 21 May 2026 06:02:17 Pacific Daylight Time Andrey Semashev via
> Std-Proposals wrote:
>>> This is useful in ternary conditional expressions, like `o.is_valid()
>>> ? *o : std::unreachable<O::value_type>()`.
>>
>> How is this different from just `*o`?
>
> The only place I see this being used is the equivalent of Qt macro
> QT_UNREACHABLE_RETURN(), which expands to:
>
> do { Q_UNREACHABLE(); return __VA_ARGS__; } while (0)
>
> 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.
> On Thursday, 21 May 2026 06:02:17 Pacific Daylight Time Andrey Semashev via
> Std-Proposals wrote:
>>> This is useful in ternary conditional expressions, like `o.is_valid()
>>> ? *o : std::unreachable<O::value_type>()`.
>>
>> How is this different from just `*o`?
>
> The only place I see this being used is the equivalent of Qt macro
> QT_UNREACHABLE_RETURN(), which expands to:
>
> do { Q_UNREACHABLE(); return __VA_ARGS__; } while (0)
>
> 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.
Received on 2026-05-21 15:58:33
