Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use argument-dependent-lookup for tuple_caster's get #5162

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,23 +685,27 @@ class tuple_caster {
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;
}
Expand All @@ -714,10 +718,11 @@ class tuple_caster {
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();
Expand Down
Loading