Introduce detail::always_false<> to make the new static_assert() more readable.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2024-12-20 17:28:41 -08:00
parent 4be50fe1a9
commit 8f87e21291
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -1372,7 +1372,7 @@ template <typename D>
template <typename T>
str_attr_accessor object_api<D>::attr_with_type_hint(const char *key) const {
#if !defined(__cpp_inline_variables)
static_assert(!std::is_same<T, T>::value,
static_assert(always_false<T>::value,
"C++17 feature __cpp_inline_variables not available: "
"https://en.cppreference.com/w/cpp/language/static#Static_data_members");
#endif

View File

@ -627,6 +627,9 @@ struct instance {
static_assert(std::is_standard_layout<instance>::value,
"Internal error: `pybind11::detail::instance` is not standard layout!");
template <typename>
struct always_false : std::false_type {};
/// from __cpp_future__ import (convenient aliases from C++14/17)
#if defined(PYBIND11_CPP14)
using std::conditional_t;