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
This commit is contained in:
Megh Parikh 2024-06-12 15:01:01 -04:00 committed by GitHub
parent ab955f158c
commit 8869be19d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -685,11 +685,11 @@ public:
protected: protected:
template <size_t... Is> template <size_t... Is>
type implicit_cast(index_sequence<Is...>) & { type implicit_cast(index_sequence<Is...>) & {
return type(cast_op<Ts>(std::get<Is>(subcasters))...); return type(cast_op<Ts>(get<Is>(subcasters))...);
} }
template <size_t... Is> template <size_t... Is>
type implicit_cast(index_sequence<Is...>) && { type implicit_cast(index_sequence<Is...>) && {
return type(cast_op<Ts>(std::move(std::get<Is>(subcasters)))...); return type(cast_op<Ts>(std::move(get<Is>(subcasters)))...);
} }
static constexpr bool load_impl(const sequence &, bool, index_sequence<>) { return true; } static constexpr bool load_impl(const sequence &, bool, index_sequence<>) { return true; }
@ -697,11 +697,11 @@ protected:
template <size_t... Is> template <size_t... Is>
bool load_impl(const sequence &seq, bool convert, index_sequence<Is...>) { bool load_impl(const sequence &seq, bool convert, index_sequence<Is...>) {
#ifdef __cpp_fold_expressions #ifdef __cpp_fold_expressions
if ((... || !std::get<Is>(subcasters).load(seq[Is], convert))) { if ((... || !get<Is>(subcasters).load(seq[Is], convert))) {
return false; return false;
} }
#else #else
for (bool r : {std::get<Is>(subcasters).load(seq[Is], convert)...}) { for (bool r : {get<Is>(subcasters).load(seq[Is], convert)...}) {
if (!r) { if (!r) {
return false; return false;
} }
@ -717,7 +717,7 @@ protected:
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent); PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent); PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent);
std::array<object, size> entries{{reinterpret_steal<object>( 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) { for (const auto &entry : entries) {
if (!entry) { if (!entry) {
return handle(); return handle();