From cb302305a3d2697f8af17a14c5bf78f45359fb56 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 23 Dec 2021 14:50:10 -0500 Subject: [PATCH] fix: restore full range of _ functions (#3571) --- include/pybind11/detail/descr.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/include/pybind11/detail/descr.h b/include/pybind11/detail/descr.h index ee72eccf..14f9223a 100644 --- a/include/pybind11/detail/descr.h +++ b/include/pybind11/detail/descr.h @@ -57,14 +57,6 @@ template constexpr descr const_name(char const(&text)[N]) { return descr(text); } constexpr descr<0> const_name(char const(&)[1]) { return {}; } -// The "_" might be defined as a macro - don't define it if so. -// Repeating the const_name code to avoid introducing a #define. -#ifndef _ -template -constexpr descr _(char const(&text)[N]) { return descr(text); } -constexpr descr<0> _(char const(&)[1]) { return {}; } -#endif - template struct int_to_str : int_to_str { }; template struct int_to_str<0, Digits...> { static constexpr auto digits = descr(('0' + Digits)...); @@ -92,6 +84,31 @@ auto constexpr const_name() -> remove_cv_t constexpr descr<1, Type> const_name() { return {'%'}; } +// The "_" might be defined as a macro - don't define it if so. +// Repeating the const_name code to avoid introducing a #define. +#ifndef _ +template +constexpr descr _(char const(&text)[N]) { return const_name(text); } +template +constexpr enable_if_t> _(char const(&text1)[N1], char const(&text2)[N2]) { + return const_name(text1, text2); +} +template +constexpr enable_if_t> _(char const(&text1)[N1], char const(&text2)[N2]) { + return const_name(text1, text2); +} +template +constexpr enable_if_t _(const T1 &d1, const T2 &d2) { return const_name(d1, d2); } +template +constexpr enable_if_t _(const T1 &d1, const T2 &d2) { return const_name(d1, d2); } + +template +auto constexpr _() -> remove_cv_t::digits)> { + return const_name(); +} +template constexpr descr<1, Type> _() { return const_name(); } +#endif + constexpr descr<0> concat() { return {}; } template