From 5bbcba548a27baf8d6bfb7993e814da24b432dbf Mon Sep 17 00:00:00 2001 From: Konstantin Bespalov Date: Fri, 24 Mar 2023 06:01:09 +0100 Subject: [PATCH] use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587) --- include/pybind11/detail/descr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/pybind11/detail/descr.h b/include/pybind11/detail/descr.h index e7a5e2c145..85259d488e 100644 --- a/include/pybind11/detail/descr.h +++ b/include/pybind11/detail/descr.h @@ -143,11 +143,24 @@ constexpr descr concat(const descr &descr) { return descr; } +#if defined(PYBIND11_CPP17) +template +constexpr descr operator,(const descr &a, + const descr &b) { + return a + const_name(", ") + b; +} + +template +constexpr auto concat(const descr &d, const Args &...args) { + return (d, ..., args); +} +#else template constexpr auto concat(const descr &d, const Args &...args) -> decltype(std::declval>() + concat(args...)) { return d + const_name(", ") + concat(args...); } +#endif template constexpr descr type_descr(const descr &descr) {