diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index d8bb7481..cb29b1dc 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -56,40 +56,6 @@ constexpr bool is_py_list_like_v> = true; template constexpr bool is_py_list_like_v> = true; -template <> -struct type_caster> { - std::vector data; - - template - static object cast(U&& src, return_value_policy policy, handle parent) { - auto list = pkbind::list(); - for(auto&& item: src) { - list.append(pkbind::cast(bool(item), policy, parent)); - } - return list; - } - - bool load(handle src, bool convert) { - if(!isinstance(src)) { return false; } - - auto list = src.cast(); - data.clear(); - data.reserve(list.size()); - - for(auto item: list) { - type_caster caster; - if(!caster.load(item, convert)) { return false; } - data.push_back(caster.value()); - } - - return true; - } - - std::vector& value() { return data; } - - constexpr inline static bool is_temporary_v = true; -}; - template struct type_caster>> { T data; @@ -98,7 +64,11 @@ struct type_caster>> { static object cast(U&& src, return_value_policy policy, handle parent) { auto list = pkbind::list(); for(auto&& item: src) { - list.append(pkbind::cast(std::move(item), policy, parent)); + if constexpr(std::is_same_v>) { + list.append(pkbind::cast(bool(item), policy, parent)); + } else { + list.append(pkbind::cast(std::move(item), policy, parent)); + } } return list; }