Projects
Eulaceura:Factory
masstree
_service:obs_scm:0001-masstree-fix-compile-erro...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-masstree-fix-compile-error-with-gcc12.patch of Package masstree
From e2ffccaf650b598a37f8131bb9ec89f515c2d554 Mon Sep 17 00:00:00 2001 From: Zheng Shaoyu <zhengshaoyu@huawei.com> Date: Thu, 21 Sep 2023 13:10:44 +0000 Subject: [PATCH] masstree-fix-compile-error-with-gcc12 --- str.hh | 20 ++++++++++++++++++-- string.hh | 14 +++++++++++++- string_base.hh | 19 ++++++++----------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/str.hh b/str.hh index 0f4b5a1..7440bcb 100644 --- a/str.hh +++ b/str.hh @@ -160,6 +160,22 @@ struct inline_string : public String_base<inline_string> { } // namespace lcdf -LCDF_MAKE_STRING_HASH(lcdf::Str) -LCDF_MAKE_STRING_HASH(lcdf::inline_string) +#if HAVE_STD_HASH + +namespace std { + template <> struct hash<lcdf::Str> : public spp_unary_function< const lcdf::Str&, size_t > { + size_t operator()(const lcdf::Str& x) const noexcept { + return x.hashcode(); + } + }; + + template <> struct hash<lcdf::inline_string> : public spp_unary_function< const lcdf::inline_string&, size_t > { + size_t operator()(const lcdf::inline_string& x) const noexcept { + return x.hashcode(); + } + }; +} // namespace std + +#endif + #endif diff --git a/string.hh b/string.hh index fa2454d..7239742 100644 --- a/string.hh +++ b/string.hh @@ -875,5 +875,17 @@ inline void swap(String& a, String& b) { } // namespace lcdf -LCDF_MAKE_STRING_HASH(lcdf::String) +#if HAVE_STD_HASH + +namespace std { + template <> struct hash<lcdf::String> : public spp_unary_function< const lcdf::String&, size_t > { + size_t operator()(const lcdf::String& x) const noexcept { + return x.hashcode(); + } + }; + +} // namespace std + +#endif + #endif diff --git a/string_base.hh b/string_base.hh index adcd717..4c36f13 100644 --- a/string_base.hh +++ b/string_base.hh @@ -22,6 +22,14 @@ #include <limits.h> #include <ctype.h> #include <iostream> + +template<class ArgumentType, class ResultType> +struct spp_unary_function +{ + typedef ArgumentType argument_type; + typedef ResultType result_type; +}; + namespace lcdf { class StringAccum; #define LCDF_CONSTANT_CSTR(cstr) ((cstr) && __builtin_constant_p(strlen((cstr)))) @@ -512,17 +520,6 @@ inline typename T::substring_type String_generic::trim(const T &str) { return str.fast_substring(b, e); } -#if HAVE_STD_HASH -# define LCDF_MAKE_STRING_HASH(type) \ - namespace std { template <> struct hash<type> \ - : public unary_function<const type&, size_t> { \ - size_t operator()(const type& x) const noexcept { \ - return x.hashcode(); \ - } }; } -#else -# define LCDF_MAKE_STRING_HASH(type) -#endif - template <typename T> template <typename E> typename String_base<T>::const_iterator String_base<T>::encode_json_partial(E& enc) const { const char *last = this->begin(), *end = this->end(); -- 2.41.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2