From 8fe13b889672ca1db697a9c178349373e55d4014 Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Mon, 5 Sep 2016 14:30:56 +0200 Subject: [PATCH] Apply make_caster and intrinsic_t aliases everywhere --- include/pybind11/attr.h | 2 +- include/pybind11/cast.h | 38 +++++++++++++++++++------------------- include/pybind11/stl.h | 18 +++++++++--------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index 638ebad72..6c413284e 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -240,7 +240,7 @@ struct process_attribute> : process_attribute_default> { r->args.emplace_back("self", nullptr, handle()); /* Convert keyword value into a Python object */ - object o = object(detail::type_caster::type>::cast( + auto o = object(detail::make_caster::cast( *a.value, return_value_policy::automatic, handle()), false); if (!o) { diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 144d2dc42..213fbd2e6 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -252,8 +252,8 @@ protected: /* Determine suitable casting operator */ template using cast_op_type = typename std::conditional::type>::value, - typename std::add_pointer::type>::type, - typename std::add_lvalue_reference::type>::type>::type; + typename std::add_pointer>::type, + typename std::add_lvalue_reference>::type>::type; /// Generic type caster for objects stored on the heap template class type_caster_base : public type_caster_generic { @@ -612,8 +612,8 @@ public: } static handle cast(const type &src, return_value_policy policy, handle parent) { - object o1 = object(type_caster::type>::cast(src.first, policy, parent), false); - object o2 = object(type_caster::type>::cast(src.second, policy, parent), false); + object o1 = object(make_caster::cast(src.first, policy, parent), false); + object o2 = object(make_caster::cast(src.second, policy, parent), false); if (!o1 || !o2) return handle(); tuple result(2); @@ -624,24 +624,24 @@ public: static PYBIND11_DESCR name() { return type_descr( - _("Tuple[") + type_caster::type>::name() + - _(", ") + type_caster::type>::name() + _("]")); + _("Tuple[") + make_caster::name() + _(", ") + make_caster::name() + _("]") + ); } template using cast_op_type = type; operator type() { - return type(first .operator typename type_caster::type>::template cast_op_type(), - second.operator typename type_caster::type>::template cast_op_type()); + return type(first.operator typename make_caster::template cast_op_type(), + second.operator typename make_caster::template cast_op_type()); } protected: - type_caster::type> first; - type_caster::type> second; + make_caster first; + make_caster second; }; template class type_caster> { typedef std::tuple type; - typedef std::tuple::type...> itype; + typedef std::tuple...> itype; typedef std::tuple args_type; typedef std::tuple args_kwargs_type; public: @@ -681,7 +681,7 @@ public: } static PYBIND11_DESCR element_names() { - return detail::concat(type_caster::type>::name()...); + return detail::concat(make_caster::name()...); } static PYBIND11_DESCR name() { @@ -706,12 +706,12 @@ public: protected: template ReturnValue call(Func &&f, index_sequence) { return f(std::get(value) - .operator typename type_caster::type>::template cast_op_type()...); + .operator typename make_caster::template cast_op_type()...); } template type cast(index_sequence) { return type(std::get(value) - .operator typename type_caster::type>::template cast_op_type()...); + .operator typename make_caster::template cast_op_type()...); } template bool load(handle src, bool convert, index_sequence) { @@ -728,7 +728,7 @@ protected: /* Implementation: Convert a C++ tuple into a Python tuple */ template static handle cast(const type &src, return_value_policy policy, handle parent, index_sequence) { std::array entries {{ - object(type_caster::type>::cast(std::get(src), policy, parent), false)... + object(make_caster::cast(std::get(src), policy, parent), false)... }}; for (const auto &entry: entries) if (!entry) @@ -741,7 +741,7 @@ protected: } protected: - std::tuple::type>...> value; + std::tuple...> value; }; /// Type caster for holder types like std::shared_ptr, etc. @@ -848,7 +848,7 @@ template using move_never = std::integral_constant T cast(const handle &handle) { - typedef detail::type_caster::type> type_caster; + using type_caster = detail::make_caster; type_caster conv; if (!conv.load(handle, true)) { #if defined(NDEBUG) @@ -868,7 +868,7 @@ template object cast(const T &value, policy = std::is_pointer::value ? return_value_policy::take_ownership : return_value_policy::copy; else if (policy == return_value_policy::automatic_reference) policy = std::is_pointer::value ? return_value_policy::reference : return_value_policy::copy; - return object(detail::type_caster::type>::cast(value, policy, parent), false); + return object(detail::make_caster::cast(value, policy, parent), false); } template T handle::cast() const { return pybind11::cast(*this); } @@ -929,7 +929,7 @@ template tuple make_tuple(Args&&... args_) { const size_t size = sizeof...(Args); std::array args { - { object(detail::type_caster::type>::cast( + { object(detail::make_caster::cast( std::forward(args_), policy, nullptr), false)... } }; for (auto &arg_value : args) { diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 2c47841b5..4390efac9 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -26,8 +26,8 @@ NAMESPACE_BEGIN(pybind11) NAMESPACE_BEGIN(detail) template struct set_caster { - typedef Type type; - typedef type_caster::type> key_conv; + using type = Type; + using key_conv = make_caster; bool load(handle src, bool convert) { pybind11::set s(src, true); @@ -57,9 +57,9 @@ template struct set_caster { }; template struct map_caster { - typedef Type type; - typedef type_caster::type> key_conv; - typedef type_caster::type> value_conv; + using type = Type; + using key_conv = make_caster; + using value_conv = make_caster; bool load(handle src, bool convert) { dict d(src, true); @@ -93,8 +93,8 @@ template struct map_caster { }; template struct list_caster { - typedef Type type; - typedef type_caster::type> value_conv; + using type = Type; + using value_conv = make_caster; bool load(handle src, bool convert) { list l(src, true); @@ -138,8 +138,8 @@ template struct type_caster, Type> { }; template struct type_caster> { - typedef std::array array_type; - typedef type_caster::type> value_conv; + using array_type = std::array; + using value_conv = make_caster; bool load(handle src, bool convert) { list l(src, true);