diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 3af673511..38eb8a88f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1432,9 +1432,14 @@ protected: template bool load_impl(const sequence &seq, bool convert, index_sequence) { +#ifdef __cpp_fold_expressions + if ((... || !std::get(subcasters).load(seq[Is], convert))) + return false; +#else for (bool r : {std::get(subcasters).load(seq[Is], convert)...}) if (!r) return false; +#endif return true; } @@ -1961,9 +1966,14 @@ private: template bool load_impl_sequence(function_call &call, index_sequence) { +#ifdef __cpp_fold_expressions + if ((... || !std::get(argcasters).load(call.args[Is], call.args_convert[Is]))) + return false; +#else for (bool r : {std::get(argcasters).load(call.args[Is], call.args_convert[Is])...}) if (!r) return false; +#endif return true; }