Skip to content

Instantly share code, notes, and snippets.

@johnbanq
Created August 24, 2023 19:35
Show Gist options
  • Save johnbanq/3fd1cd94e5681cfd5ed006e1c17efdf2 to your computer and use it in GitHub Desktop.
Save johnbanq/3fd1cd94e5681cfd5ed006e1c17efdf2 to your computer and use it in GitHub Desktop.
patch for fixing the header file in pytorch3d #1024
diff --git a/cast.h b/cast.h
index 0caccdb..f2e1db1 100644
--- a/cast.h
+++ b/cast.h
@@ -1424,6 +1424,16 @@ public:
template <typename _T> using cast_op_type = pybind11::detail::cast_op_type<_T>;
};
+// Base implementation for std::tuple and std::pair
+template <template <typename...> class Tuple, typename... Ts>
+class tuple_caster;
+
+template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
+ : public tuple_caster<std::pair, T1, T2> {};
+
+template <typename... Ts> class type_caster<std::tuple<Ts...>>
+ : public tuple_caster<std::tuple, Ts...> {};
+
// Base implementation for std::tuple and std::pair
template <template<typename...> class Tuple, typename... Ts> class tuple_caster {
using type = Tuple<Ts...>;
@@ -1503,12 +1513,6 @@ protected:
Tuple<make_caster<Ts>...> subcasters;
};
-template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
- : public tuple_caster<std::pair, T1, T2> {};
-
-template <typename... Ts> class type_caster<std::tuple<Ts...>>
- : public tuple_caster<std::tuple, Ts...> {};
-
/// Helper class which abstracts away certain actions. Users can provide specializations for
/// custom holders, but it's only necessary if the type has a non-standard interface.
template <typename T>
@jhuangBU
Copy link

jhuangBU commented Dec 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment