C++ Logo


Advanced search

Re: Static Failure - Custom Compile-Time Errors

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Fri, 18 Jun 2021 20:19:50 +0200

Il 18/06/21 19:52, Arthur O'Dwyer via Std-Proposals ha scritto:
> Since nobody's mentioned it yet:
> static_assert(sizeof(T) != 0, "this condition is dependent, yet
> always false");
> No wording change needed.

Should one still need to modify
https://eel.is/c++draft/temp#res.general-6.1 somehow? The "and the
template is not instantiated" sounds like a lifeline in application code
if you're sure you're instantiating a given function template, but what
if you're writing a library and you don't know that?

Also I'd really like something more streamlined than the workarounds
usually deployed here, all along the lines of what you wrote (sizeof(T)
!= 0, sizeof(T*)!=0, !std::is_same_v<T, T>, always_false<T>, and so on
and so forth). But I'm scared of the implications of, say,
special-casing static_assert so it's always value-dependent.

Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2021-06-18 13:19:58