Skip to content

Commit 00c0fd5

Browse files
committed
Update MSVC macro to remove condition duplication
Repeating the conditions is a bit annoying, and error-prone; use some macro programming to elimate the duplication.
1 parent 68fcb26 commit 00c0fd5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/pybind11/pybind11.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,18 @@ class class_ : public detail::generic_type {
825825
template <typename T> using is_base_class = detail::bool_constant<std::is_base_of<T, type_>::value && !std::is_same<T, type_>::value>;
826826
#if defined(_MSC_VER) // MSVC fails with the below type alias, unable to find the is_holder, is_subtype, etc. predicate types
827827
template <typename T> struct is_valid_class_option :
828-
detail::bool_constant<is_holder<T>::value || is_subtype<T>::value || is_base_class<T>::value> {};
829828
#else
830829
template <typename T> using is_valid_class_option =
831-
detail::bool_constant<is_holder<T>::value || is_subtype<T>::value || is_base_class<T>::value>;
832830
#endif
831+
detail::bool_constant<
832+
is_holder<T>::value ||
833+
is_subtype<T>::value ||
834+
is_base_class<T>::value
835+
>
836+
#if defined(_MSC_VER)
837+
{}
838+
#endif
839+
;
833840

834841
using extracted_holder_t = typename detail::first_of_t<is_holder, options...>;
835842

0 commit comments

Comments
 (0)