diff options
| author | Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> | 2025-03-12 23:55:05 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-03-14 08:29:23 +0000 |
| commit | 8be7a10b43804fc4ebef712892e45bba26647d1f (patch) | |
| tree | e35e348b67f0306613b1712a0bcf4ea7fde82233 /apt-pkg | |
| parent | db5267cc17b3b2e6ded25da60adc030124950ae4 (diff) | |
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.
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/solver3.h | 4 |
1 files changed, 3 insertions, 1 deletions
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 <apt-pkg/pkgcache.h> #include <apt-pkg/policy.h> +template <typename T> struct always_false : std::false_type {}; + namespace APT { @@ -49,7 +51,7 @@ class ContiguousCacheMap else if constexpr (std::is_same_v<K, pkgCache::Package>) size = cache.Head().PackageCount; else - static_assert(false, "Cannot construct map for key type"); + static_assert(always_false<K>::value, "Cannot construct map for key type"); data_ = new V[size]{}; } |
