Compare commits

...

4 Commits

Author SHA1 Message Date
Megh Parikh 1624a0b7fe
Merge 5f815052b0 into a7910be630 2024-09-15 08:56:02 -07:00
pre-commit-ci[bot] 5f815052b0 style: pre-commit fixes 2024-06-12 19:09:48 +00:00
Megh Parikh b8336a8bb7
Update cast.h 2024-06-12 15:09:21 -04:00
Megh Parikh 8869be19d8
Use argument-dependent-lookup for tuple_caster's get
Some libraries have custom container types and define their own `get`. They also extend the Pybind casters to bind their containers. This uses argument-dependent-lookup  for using the correct "get" function
2024-06-12 15:01:01 -04:00
1 changed files with 10 additions and 5 deletions

View File

@ -685,23 +685,27 @@ public:
protected:
template <size_t... Is>
type implicit_cast(index_sequence<Is...>) & {
return type(cast_op<Ts>(std::get<Is>(subcasters))...);
using std::get;
return type(cast_op<Ts>(get<Is>(subcasters))...);
}
template <size_t... Is>
type implicit_cast(index_sequence<Is...>) && {
return type(cast_op<Ts>(std::move(std::get<Is>(subcasters)))...);
using std::get;
return type(cast_op<Ts>(std::move(get<Is>(subcasters)))...);
}
static constexpr bool load_impl(const sequence &, bool, index_sequence<>) { return true; }
template <size_t... Is>
bool load_impl(const sequence &seq, bool convert, index_sequence<Is...>) {
using std::get;
#ifdef __cpp_fold_expressions
if ((... || !std::get<Is>(subcasters).load(seq[Is], convert))) {
if ((... || !get<Is>(subcasters).load(seq[Is], convert))) {
return false;
}
#else
for (bool r : {std::get<Is>(subcasters).load(seq[Is], convert)...}) {
for (bool r : {get<Is>(subcasters).load(seq[Is], convert)...}) {
if (!r) {
return false;
}
@ -714,10 +718,11 @@ protected:
template <typename T, size_t... Is>
static handle
cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
using std::get;
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent);
std::array<object, size> entries{{reinterpret_steal<object>(
make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...}};
make_caster<Ts>::cast(get<Is>(std::forward<T>(src)), policy, parent))...}};
for (const auto &entry : entries) {
if (!entry) {
return handle();