From 8be7a10b43804fc4ebef712892e45bba26647d1f Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Wed, 12 Mar 2025 23:55:05 +0100 Subject: apt-pkg/solver3.h: avoid static_assert(false) With older compilers (g++ and clang from Bookworm), static_assert(false) will result in: /home/josch/git/apt/build/include/apt-pkg/solver3.h:52:24: error: static assertion failed: Cannot construct map for key type 52 | static_assert(false, "Cannot construct map for key type"); | ^~~~~ This commit implements the terrible but more valid workaround according to: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html Original solution from here: https://stackoverflow.com/questions/14637356/static-assert-fails-compilation-even-though-template-function-is-called-nowhere/14637534#14637534 That way, apt will compile with compilers in Bookworm again. --- apt-pkg/solver3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 1bdc13559..c2d6e035e 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -19,6 +19,8 @@ #include #include +template struct always_false : std::false_type {}; + namespace APT { @@ -49,7 +51,7 @@ class ContiguousCacheMap else if constexpr (std::is_same_v) size = cache.Head().PackageCount; else - static_assert(false, "Cannot construct map for key type"); + static_assert(always_false::value, "Cannot construct map for key type"); data_ = new V[size]{}; } -- cgit v1.2.3-70-g09d2