From 8869be19d8d230694ec375ddf02e1011587a872e Mon Sep 17 00:00:00 2001 From: Megh Parikh Date: Wed, 12 Jun 2024 15:01:01 -0400 Subject: [PATCH 1/3] 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 --- include/pybind11/cast.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 624b8ebac..23c4c5f6e 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -685,11 +685,11 @@ public: protected: template type implicit_cast(index_sequence) & { - return type(cast_op(std::get(subcasters))...); + return type(cast_op(get(subcasters))...); } template type implicit_cast(index_sequence) && { - return type(cast_op(std::move(std::get(subcasters)))...); + return type(cast_op(std::move(get(subcasters)))...); } static constexpr bool load_impl(const sequence &, bool, index_sequence<>) { return true; } @@ -697,11 +697,11 @@ protected: template bool load_impl(const sequence &seq, bool convert, index_sequence) { #ifdef __cpp_fold_expressions - if ((... || !std::get(subcasters).load(seq[Is], convert))) { + if ((... || !get(subcasters).load(seq[Is], convert))) { return false; } #else - for (bool r : {std::get(subcasters).load(seq[Is], convert)...}) { + for (bool r : {get(subcasters).load(seq[Is], convert)...}) { if (!r) { return false; } @@ -717,7 +717,7 @@ protected: PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent); PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent); std::array entries{{reinterpret_steal( - make_caster::cast(std::get(std::forward(src)), policy, parent))...}}; + make_caster::cast(get(std::forward(src)), policy, parent))...}}; for (const auto &entry : entries) { if (!entry) { return handle(); From b8336a8bb79754681f89300395b5c3b43c3ba95a Mon Sep 17 00:00:00 2001 From: Megh Parikh Date: Wed, 12 Jun 2024 15:09:21 -0400 Subject: [PATCH 2/3] Update cast.h --- include/pybind11/cast.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 23c4c5f6e..acf1a670f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -685,10 +685,12 @@ public: protected: template type implicit_cast(index_sequence) & { + using std::get; return type(cast_op(get(subcasters))...); } template type implicit_cast(index_sequence) && { + using std::get; return type(cast_op(std::move(get(subcasters)))...); } @@ -696,6 +698,8 @@ protected: template bool load_impl(const sequence &seq, bool convert, index_sequence) { + using std::get; + #ifdef __cpp_fold_expressions if ((... || !get(subcasters).load(seq[Is], convert))) { return false; @@ -714,6 +718,7 @@ protected: template static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence) { + using std::get; PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent); PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent); std::array entries{{reinterpret_steal( From 5f815052b0bd74f571d3353afdc406e7dfcbfbca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:09:48 +0000 Subject: [PATCH 3/3] style: pre-commit fixes --- include/pybind11/cast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index acf1a670f..ee3d20549 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -699,7 +699,7 @@ protected: template bool load_impl(const sequence &seq, bool convert, index_sequence) { using std::get; - + #ifdef __cpp_fold_expressions if ((... || !get(subcasters).load(seq[Is], convert))) { return false;