Skip to content

Commit

Permalink
fix backwards compatibly const_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Dec 12, 2024
1 parent 16934a7 commit 7f8eaf0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion include/pybind11/detail/descr.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,23 @@ constexpr enable_if_t<!B, T2> _(const T1 &d1, const T2 &d2) {
return const_name<B, T1, T2>(d1, d2);
}

template <auto Size>
#if defined(PYBIND11_CPP17)

template <auto Bool,
typename std::enable_if<std::is_same<decltype(Bool), bool>::value, int>::type = 0>
auto constexpr _() {
return const_name<Bool>();
}

template <auto Size,
typename std::enable_if<!std::is_same<decltype(Size), bool>::value, int>::type = 0>
#else
template <size_t Size>
#endif
auto constexpr _() -> remove_cv_t<decltype(int_to_str<Size / 10, Size % 10>::digits)> {
return const_name<Size>();
}

template <typename Type>
constexpr descr<1, Type> _() {
return const_name<Type>();
Expand Down

0 comments on commit 7f8eaf0

Please sign in to comment.