The patch contains 2 upstream changes needed for building with GCC 12. From e06d2c95bf88f84f9e570eeece5c3408fd8f24fe Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Mon, 14 Mar 2022 16:10:12 +0100 Subject: [PATCH] Move mult operator for str to the appropriate ns --- pythran/pythonic/include/types/str.hpp | 11 +++-- pythran/pythonic/types/str.hpp | 64 +++++++++++++------------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/pythran/pythonic/include/types/str.hpp b/pythran/pythonic/include/types/str.hpp index 329de1c1d..5aa526692 100644 --- a/pythran/pythonic/include/types/str.hpp +++ b/pythran/pythonic/include/types/str.hpp @@ -318,6 +318,12 @@ namespace types std::ostream &operator<<(std::ostream &os, chr const &s); std::ostream &operator<<(std::ostream &os, str const &s); + + str operator*(str const &s, long n); + str operator*(long t, str const &s); + str operator*(chr const &s, long n); + str operator*(long t, chr const &s); + } namespace operator_ @@ -356,11 +362,6 @@ struct assignable { }; PYTHONIC_NS_END -pythonic::types::str operator*(pythonic::types::str const &s, long n); -pythonic::types::str operator*(long t, pythonic::types::str const &s); -pythonic::types::str operator*(pythonic::types::chr const &s, long n); -pythonic::types::str operator*(long t, pythonic::types::chr const &s); - namespace std { template <> diff --git a/pythran/pythonic/types/str.hpp b/pythran/pythonic/types/str.hpp index 6e9bc241f..ee540a73b 100644 --- a/pythran/pythonic/types/str.hpp +++ b/pythran/pythonic/types/str.hpp @@ -655,6 +655,38 @@ namespace types { return os << s.c_str(); } + + str operator*(str const &s, long n) + { + if (n <= 0) + return str(); + str other; + other.resize(s.size() * n); + auto where = other.chars().begin(); + for (long i = 0; i < n; i++, where += s.size()) + std::copy(s.chars().begin(), s.chars().end(), where); + return other; + } + + str operator*(long t, str const &s) + { + return s * t; + } + + str operator*(chr const &s, long n) + { + if (n <= 0) + return str(); + str other; + other.resize(n); + std::fill(other.chars().begin(), other.chars().end(), s.c); + return other; + } + + str operator*(long t, chr const &c) + { + return c * t; + } } namespace operator_ @@ -686,38 +718,6 @@ namespace operator_ } PYTHONIC_NS_END -pythonic::types::str operator*(pythonic::types::str const &s, long n) -{ - if (n <= 0) - return pythonic::types::str(); - pythonic::types::str other; - other.resize(s.size() * n); - auto where = other.chars().begin(); - for (long i = 0; i < n; i++, where += s.size()) - std::copy(s.chars().begin(), s.chars().end(), where); - return other; -} - -pythonic::types::str operator*(long t, pythonic::types::str const &s) -{ - return s * t; -} - -pythonic::types::str operator*(pythonic::types::chr const &s, long n) -{ - if (n <= 0) - return pythonic::types::str(); - pythonic::types::str other; - other.resize(n); - std::fill(other.chars().begin(), other.chars().end(), s.c); - return other; -} - -pythonic::types::str operator*(long t, pythonic::types::chr const &c) -{ - return c * t; -} - namespace std { From 343cb724d857fe8adcef071ab088df2c02ba0d4c Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 14 Mar 2022 10:11:00 +0000 Subject: [PATCH] Add default constructor to string_iterator A type must be default constructible to meet the forward iterator requirements. GCC 12 won't compile `std::reverse_iterator` without this change. --- pythran/pythonic/include/types/str.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/pythran/pythonic/include/types/str.hpp b/pythran/pythonic/include/types/str.hpp index 329de1c1d..a0df45905 100644 --- a/pythran/pythonic/include/types/str.hpp +++ b/pythran/pythonic/include/types/str.hpp @@ -231,6 +231,7 @@ namespace types struct string_iterator : std::iterator { std::string::const_iterator curr; + string_iterator() = default; string_iterator(std::string::const_iterator iter) : curr(iter) { }