From 5d4b6890a337ae1bbaec4091f4195606f89a3b06 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Fri, 12 Feb 2021 13:46:18 -0800 Subject: [PATCH] Systematically replacing `detail::enable_if_t<...smart_holder...>` with `typename std::enable_if<...smart_holder...>::type`. Attempt to work around MSVC 2015 issues, to be tested via GitHub CI. The idea for this change originates from this comment: https://github.com/pybind/pybind11/issues/1616#issuecomment-444536813 --- include/pybind11/cast.h | 2 +- include/pybind11/detail/init.h | 6 +++--- include/pybind11/pybind11.h | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 784974d1e..4999b6bec 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -2459,7 +2459,7 @@ struct is_smart_holder_type_caster : std::false_type {}; template struct is_smart_holder_type_caster< T, - enable_if_t::is_smart_holder_type_caster::value, void>> : std::true_type {}; + typename std::enable_if::is_smart_holder_type_caster::value, void>::type> : std::true_type {}; template inline bool check_is_smart_holder_type_caster() { diff --git a/include/pybind11/detail/init.h b/include/pybind11/detail/init.h index b351f21d1..ef5eb0da8 100644 --- a/include/pybind11/detail/init.h +++ b/include/pybind11/detail/init.h @@ -132,7 +132,7 @@ void construct(value_and_holder &v_h, Alias *alias_ptr, bool) { // holder. This also handles types like std::shared_ptr and std::unique_ptr where T is a // derived type (through those holder's implicit conversion from derived class holder constructors). template >::value, int> = 0> + typename std::enable_if>::value, int>::type = 0> void construct(value_and_holder &v_h, Holder holder, bool need_alias) { auto *ptr = holder_helper>::get(holder); no_nullptr(ptr); @@ -172,7 +172,7 @@ void construct(value_and_holder &v_h, Alias &&result, bool) { //DETAIL/SMART_HOLDER_INIT_H/BEGIN///////////////////////////////////////////////////////////////// template >, - detail::enable_if_t>::value, int> = 0> + typename std::enable_if>::value, int>::type = 0> void construct(value_and_holder &v_h, std::unique_ptr, D> &&unq_ptr, bool need_alias) { auto *ptr = unq_ptr.get(); no_nullptr(ptr); @@ -188,7 +188,7 @@ void construct(value_and_holder &v_h, std::unique_ptr, D> &&unq_ptr, } template >::value, int> = 0> + typename std::enable_if>::value, int>::type = 0> void construct(value_and_holder &v_h, std::shared_ptr> &&shd_ptr, bool need_alias) { auto *ptr = shd_ptr.get(); no_nullptr(ptr); diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 6ddaa4740..510720c57 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1544,14 +1544,14 @@ public: private: template < typename T = type, - detail::enable_if_t::value, int> = 0> + typename std::enable_if::value, int>::type = 0> void generic_type_initialize(const detail::type_record &record) { generic_type::initialize(record, &detail::type_caster_generic::local_load); } template < typename T = type, - detail::enable_if_t::value, int> = 0> + typename std::enable_if::value, int>::type = 0> void generic_type_initialize(const detail::type_record &record) { generic_type::initialize(record, detail::type_caster::get_local_load_function_ptr()); } @@ -1602,7 +1602,7 @@ private: /// `.owned`, a new holder will be constructed to manage the value pointer. template < typename T = type, - detail::enable_if_t::value, int> = 0> + typename std::enable_if::value, int>::type = 0> static void init_instance(detail::instance *inst, const void *holder_ptr) { auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type))); if (!v_h.instance_registered()) { @@ -1614,7 +1614,7 @@ private: template < typename T = type, - detail::enable_if_t::value, int> = 0> + typename std::enable_if::value, int>::type = 0> static void init_instance(detail::instance *inst, const void *holder_ptr) { detail::type_caster::template init_instance_for_type(inst, holder_ptr); }