File: 0010-Define-cmp_str-call-operator-as-const.patch

package info (click to toggle)
brainparty 0.61%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,656 kB
  • sloc: cpp: 12,991; objc: 252; makefile: 61
file content (33 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From: "Henrique F. Simoes" <henriquesimoes@riseup.net>
Date: Wed, 8 Oct 2025 22:18:35 -0300
Subject: Define cmp_str call operator as const

Because this custom comparator is used as constant reference in the
std::map implementation, its methods cannot change its internal state.
Declare that the function call operator doesn't do that, and therefore
can be called whenever we have a constant reference.

This resolves an issue when building with GCC 15, where no matching
method would be found:

/usr/include/c++/15/bits/stl_tree.h:2604:36: error: no match for call to
‘(const cmp_str) (const char* const&, const char* const&)’

Bug-Debian: https://bugs.debian.org/1096391
---
 BPGame.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BPGame.h b/BPGame.h
index 19e5721..ebcbfa3 100644
--- a/BPGame.h
+++ b/BPGame.h
@@ -53,7 +53,7 @@ class BPMiniGame;
 class SpriteFont;
 
 struct cmp_str {
-	bool operator()(char const *a, char const *b) {
+	bool operator()(char const *a, char const *b) const {
 		return std::strcmp(a, b) < 0;
 	}
 };