add c++17 guard

This commit is contained in:
Michael Carlstrom 2024-12-05 21:06:24 -05:00
parent fe21e0f8d7
commit 4a443a7adf
2 changed files with 7 additions and 2 deletions

View File

@ -1329,14 +1329,18 @@ object object_or_cast(T &&o) {
return pybind11::cast(std::forward<T>(o));
}
#if defined(PYBIND11_CPP17)
// Declared in pytypes.h:
// Written here so make_caster<T> can be used
template <typename D>
template <typename T>
str_attr_accessor object_api<D>::attr_with_type(const char *key) const {
annotations()[key] = make_caster<T>::name.text;
static constexpr auto name = make_caster<T>::name;
annotations()[key] = name.text;
return {derived(), key};
}
#endif
// Placeholder type for the unneeded (and dead code) static variable in the
// PYBIND11_OVERRIDE_OVERRIDE macro

View File

@ -113,10 +113,11 @@ public:
/// See above (the only difference is that the key is provided as a string literal)
str_attr_accessor attr(const char *key) const;
#if defined(PYBIND11_CPP17)
// attr_with_type is implemented in cast.h:
template <typename T>
str_attr_accessor attr_with_type(const char *key) const;
#endif
/** \rst
Matches * unpacking in Python, e.g. to unpack arguments out of a ``tuple``
or ``list`` for a function call. Applying another * to the result yields