|
|
|
@ -30,11 +30,12 @@ namespace pybind11 {
|
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
|
|
// Can be replaced by a generic lambda in C++14
|
|
|
|
|
struct variant_caster_visitor : public boost::static_visitor<handle> {
|
|
|
|
|
struct __attribute__((visibility("hidden"))) paddle_variant_caster_visitor
|
|
|
|
|
: public boost::static_visitor<handle> {
|
|
|
|
|
return_value_policy policy;
|
|
|
|
|
handle parent;
|
|
|
|
|
|
|
|
|
|
variant_caster_visitor(return_value_policy policy, handle parent)
|
|
|
|
|
paddle_variant_caster_visitor(return_value_policy policy, handle parent)
|
|
|
|
|
: policy(policy), parent(parent) {}
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
@ -44,10 +45,10 @@ struct variant_caster_visitor : public boost::static_visitor<handle> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class Variant>
|
|
|
|
|
struct variant_caster;
|
|
|
|
|
struct paddle_variant_caster;
|
|
|
|
|
|
|
|
|
|
template <template <class...> class V, class... Ts>
|
|
|
|
|
struct variant_caster<V<Ts...>> {
|
|
|
|
|
struct paddle_variant_caster<V<Ts...>> {
|
|
|
|
|
using Type = V<Ts...>;
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
@ -90,7 +91,7 @@ struct variant_caster<V<Ts...>> {
|
|
|
|
|
|
|
|
|
|
static handle cast(Type const &src, return_value_policy policy,
|
|
|
|
|
handle parent) {
|
|
|
|
|
variant_caster_visitor visitor(policy, parent);
|
|
|
|
|
paddle_variant_caster_visitor visitor(policy, parent);
|
|
|
|
|
return boost::apply_visitor(visitor, src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,7 +102,7 @@ struct variant_caster<V<Ts...>> {
|
|
|
|
|
// Add specialization for concrete variant type
|
|
|
|
|
template <class... Args>
|
|
|
|
|
struct type_caster<boost::variant<Args...>>
|
|
|
|
|
: variant_caster<boost::variant<Args...>> {};
|
|
|
|
|
: paddle_variant_caster<boost::variant<Args...>> {};
|
|
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
} // namespace pybind11
|
|
|
|
|