Skip to content

Commit

Permalink
add c++17 guard
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Dec 6, 2024
1 parent fe21e0f commit 4a443a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ class object_api : public pyobject_tag {
/// 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
Expand Down

0 comments on commit 4a443a7

Please sign in to comment.