From 8f87e21291c785dfa4f22889c8923f6050d8cfb7 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 20 Dec 2024 17:28:41 -0800 Subject: [PATCH] Introduce `detail::always_false<>` to make the new `static_assert()` more readable. --- include/pybind11/cast.h | 2 +- include/pybind11/detail/common.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index df18157db..853165a49 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1372,7 +1372,7 @@ template template str_attr_accessor object_api::attr_with_type_hint(const char *key) const { #if !defined(__cpp_inline_variables) - static_assert(!std::is_same::value, + static_assert(always_false::value, "C++17 feature __cpp_inline_variables not available: " "https://en.cppreference.com/w/cpp/language/static#Static_data_members"); #endif diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 78173cad3..fc825f36a 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -627,6 +627,9 @@ struct instance { static_assert(std::is_standard_layout::value, "Internal error: `pybind11::detail::instance` is not standard layout!"); +template +struct always_false : std::false_type {}; + /// from __cpp_future__ import (convenient aliases from C++14/17) #if defined(PYBIND11_CPP14) using std::conditional_t;