diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index f847b084..8a3ccb4f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -774,7 +774,7 @@ protected: template class type_caster> { using type = std::tuple; - using indices = typename make_index_sequence::type; + using indices = make_index_sequence; static constexpr auto size = sizeof...(Tuple); public: @@ -1205,7 +1205,7 @@ NAMESPACE_BEGIN(detail) template class argument_loader { using itypes = type_list...>; - using indices = typename make_index_sequence::type; + using indices = make_index_sequence; public: static constexpr auto has_kwargs = std::is_same>::value; diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 5622ad95..72e8e33e 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -346,9 +346,15 @@ struct internals { inline internals &get_internals(); /// Index sequence for convenient template metaprogramming involving tuples +#ifdef PYBIND11_CPP14 +using std::index_sequence; +using std::make_index_sequence; +#else template struct index_sequence { }; -template struct make_index_sequence : make_index_sequence { }; -template struct make_index_sequence <0, S...> { typedef index_sequence type; }; +template struct make_index_sequence_impl : make_index_sequence_impl { }; +template struct make_index_sequence_impl <0, S...> { typedef index_sequence type; }; +template using make_index_sequence = typename make_index_sequence_impl::type; +#endif /// Strip the class from a method type template struct remove_class { }; diff --git a/include/pybind11/descr.h b/include/pybind11/descr.h index a9a1f67a..22e94ef9 100644 --- a/include/pybind11/descr.h +++ b/include/pybind11/descr.h @@ -22,8 +22,8 @@ template class descr { public: constexpr descr(char const (&text) [Size1+1], const std::type_info * const (&types)[Size2+1]) : descr(text, types, - typename make_index_sequence::type(), - typename make_index_sequence::type()) { } + make_index_sequence(), + make_index_sequence()) { } constexpr const char *text() const { return m_text; } constexpr const std::type_info * const * types() const { return m_types; } @@ -31,10 +31,10 @@ public: template constexpr descr operator+(const descr &other) const { return concat(other, - typename make_index_sequence::type(), - typename make_index_sequence::type(), - typename make_index_sequence::type(), - typename make_index_sequence::type()); + make_index_sequence(), + make_index_sequence(), + make_index_sequence(), + make_index_sequence()); } protected: diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 8950cb7c..e6f4efdf 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -1077,7 +1077,7 @@ struct vectorize_helper { explicit vectorize_helper(T&&f) : f(std::forward(f)) { } object operator()(array_t... args) { - return run(args..., typename make_index_sequence::type()); + return run(args..., make_index_sequence()); } template object run(array_t&... args, index_sequence index) {