Skip to content

Commit 8f87e21

Browse files
committed
Introduce detail::always_false<> to make the new static_assert() more readable.
1 parent 4be50fe commit 8f87e21

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/pybind11/cast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ template <typename D>
13721372
template <typename T>
13731373
str_attr_accessor object_api<D>::attr_with_type_hint(const char *key) const {
13741374
#if !defined(__cpp_inline_variables)
1375-
static_assert(!std::is_same<T, T>::value,
1375+
static_assert(always_false<T>::value,
13761376
"C++17 feature __cpp_inline_variables not available: "
13771377
"https://en.cppreference.com/w/cpp/language/static#Static_data_members");
13781378
#endif

include/pybind11/detail/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ struct instance {
627627
static_assert(std::is_standard_layout<instance>::value,
628628
"Internal error: `pybind11::detail::instance` is not standard layout!");
629629

630+
template <typename>
631+
struct always_false : std::false_type {};
632+
630633
/// from __cpp_future__ import (convenient aliases from C++14/17)
631634
#if defined(PYBIND11_CPP14)
632635
using std::conditional_t;

0 commit comments

Comments
 (0)