Skip to content

Commit

Permalink
Introduce detail::always_false<> to make the new static_assert()
Browse files Browse the repository at this point in the history
…more readable.
  • Loading branch information
rwgk committed Dec 21, 2024
1 parent 4be50fe commit 8f87e21
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f87e21

Please sign in to comment.