Skip to content

Commit 5d4b689

Browse files
committed
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: #1616 (comment)
1 parent 7aa604d commit 5d4b689

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Diff for: include/pybind11/cast.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ struct is_smart_holder_type_caster : std::false_type {};
24592459
template <typename T>
24602460
struct is_smart_holder_type_caster<
24612461
T,
2462-
enable_if_t<type_caster<T>::is_smart_holder_type_caster::value, void>> : std::true_type {};
2462+
typename std::enable_if<type_caster<T>::is_smart_holder_type_caster::value, void>::type> : std::true_type {};
24632463

24642464
template <typename T>
24652465
inline bool check_is_smart_holder_type_caster() {

Diff for: include/pybind11/detail/init.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) {
132132
// holder. This also handles types like std::shared_ptr<T> and std::unique_ptr<T> where T is a
133133
// derived type (through those holder's implicit conversion from derived class holder constructors).
134134
template <typename Class,
135-
detail::enable_if_t<!detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
135+
typename std::enable_if<!detail::is_smart_holder_type_caster<Cpp<Class>>::value, int>::type = 0>
136136
void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
137137
auto *ptr = holder_helper<Holder<Class>>::get(holder);
138138
no_nullptr(ptr);
@@ -172,7 +172,7 @@ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
172172
//DETAIL/SMART_HOLDER_INIT_H/BEGIN/////////////////////////////////////////////////////////////////
173173

174174
template <typename Class, typename D = std::default_delete<Cpp<Class>>,
175-
detail::enable_if_t<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
175+
typename std::enable_if<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int>::type = 0>
176176
void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, bool need_alias) {
177177
auto *ptr = unq_ptr.get();
178178
no_nullptr(ptr);
@@ -188,7 +188,7 @@ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr,
188188
}
189189

190190
template <typename Class,
191-
detail::enable_if_t<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int> = 0>
191+
typename std::enable_if<detail::is_smart_holder_type_caster<Cpp<Class>>::value, int>::type = 0>
192192
void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, bool need_alias) {
193193
auto *ptr = shd_ptr.get();
194194
no_nullptr(ptr);

Diff for: include/pybind11/pybind11.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1544,14 +1544,14 @@ class class_ : public detail::generic_type {
15441544
private:
15451545
template <
15461546
typename T = type,
1547-
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
1547+
typename std::enable_if<!detail::is_smart_holder_type_caster<T>::value, int>::type = 0>
15481548
void generic_type_initialize(const detail::type_record &record) {
15491549
generic_type::initialize(record, &detail::type_caster_generic::local_load);
15501550
}
15511551

15521552
template <
15531553
typename T = type,
1554-
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0>
1554+
typename std::enable_if<detail::is_smart_holder_type_caster<T>::value, int>::type = 0>
15551555
void generic_type_initialize(const detail::type_record &record) {
15561556
generic_type::initialize(record, detail::type_caster<T>::get_local_load_function_ptr());
15571557
}
@@ -1602,7 +1602,7 @@ class class_ : public detail::generic_type {
16021602
/// `.owned`, a new holder will be constructed to manage the value pointer.
16031603
template <
16041604
typename T = type,
1605-
detail::enable_if_t<!detail::is_smart_holder_type_caster<T>::value, int> = 0>
1605+
typename std::enable_if<!detail::is_smart_holder_type_caster<T>::value, int>::type = 0>
16061606
static void init_instance(detail::instance *inst, const void *holder_ptr) {
16071607
auto v_h = inst->get_value_and_holder(detail::get_type_info(typeid(type)));
16081608
if (!v_h.instance_registered()) {
@@ -1614,7 +1614,7 @@ class class_ : public detail::generic_type {
16141614

16151615
template <
16161616
typename T = type,
1617-
detail::enable_if_t<detail::is_smart_holder_type_caster<T>::value, int> = 0>
1617+
typename std::enable_if<detail::is_smart_holder_type_caster<T>::value, int>::type = 0>
16181618
static void init_instance(detail::instance *inst, const void *holder_ptr) {
16191619
detail::type_caster<T>::template init_instance_for_type<type>(inst, holder_ptr);
16201620
}

0 commit comments

Comments
 (0)