From f9d9356d51f28210ccf0c0dda508502f222e1def Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Tue, 6 Jul 2021 20:49:38 +0200 Subject: [PATCH] Fix #132, regex compilation issues for boost 1.76. It looks like they switched to a different hash function that uses integer operations on characters. --- src/util/regex.hpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/util/regex.hpp b/src/util/regex.hpp index 54276f20..179fd0de 100644 --- a/src/util/regex.hpp +++ b/src/util/regex.hpp @@ -31,23 +31,18 @@ // ----------------------------------------------------------------------------- : Boost implementation #if USE_BOOST_REGEX - // needed for boost::regex - inline std::size_t hash_value(wxUniChar const& x) { - boost::hash hasher; - return hasher(static_cast(x)); - } - /* - // fix: boost regex doesn't like that wxUniChar can't be constructed from an int - namespace boost { - namespace BOOST_REGEX_DETAIL_NS { - inline bool can_start(wxUniChar c, const unsigned char* map, unsigned char mask) { - return can_start(c.GetValue(), map, mask); - } - inline bool can_start(wxUniCharRef c, const unsigned char* map, unsigned char mask) { - return can_start(c.GetValue(), map, mask); - } + // needed for boost::regex to compute hash values of unicode chars + #if BOOST_VERSION < 107600 + inline std::size_t hash_value(wxUniChar const& x) { + boost::hash hasher; + return hasher(static_cast(x)); } - }*/ + #else + // boost > 1.76 uses its own hash function that needs operator + + inline int operator + (wxUniChar x, unsigned int y) { + return static_cast(x) + y; + } + #endif /// Our own regular expression wrapper /** Suppors both boost::regex and wxRegEx.