Skip to content

Commit 68e089a

Browse files
jcelerierdean0x7d
authored andcommitted
Use custom definitions for negation and bool_constant (#737)
Instead of relying on sometimes missing C++17 definitions
1 parent cabbf61 commit 68e089a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

include/pybind11/common.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,9 @@ template<size_t ...S> struct make_index_sequence_impl <0, S...> { typedef index_
396396
template<size_t N> using make_index_sequence = typename make_index_sequence_impl<N>::type;
397397
#endif
398398

399-
#if defined(PYBIND11_CPP17) || defined(_MSC_VER)
400-
using std::bool_constant;
401-
using std::negation;
402-
#else
399+
/// Backports of std::bool_constant and std::negation to accomodate older compilers
403400
template <bool B> using bool_constant = std::integral_constant<bool, B>;
404-
template <class T> using negation = bool_constant<!T::value>;
405-
#endif
401+
template <typename T> struct negation : bool_constant<!T::value> { };
406402

407403
/// Compile-time all/any/none of that check the boolean value of all template types
408404
#ifdef PYBIND11_CPP17

0 commit comments

Comments
 (0)