[glibmm/glibmm-2-66] Deprecate Glib::BalancedTree in favour of std::map



commit f928b301026af0ce5739128382bc492768519615
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Tue Jan 12 11:14:39 2021 +0100

    Deprecate Glib::BalancedTree in favour of std::map
    
    or std::unordered_map. See issue #78

 glib/src/balancedtree.hg   |  4 +++-
 tests/glibmm_btree/main.cc | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/glib/src/balancedtree.hg b/glib/src/balancedtree.hg
index 9eb58fe6..9b8d6598 100644
--- a/glib/src/balancedtree.hg
+++ b/glib/src/balancedtree.hg
@@ -16,6 +16,8 @@
 
 _DEFS(glibmm,glib)
 
+_IS_DEPRECATED // This whole file is deprecated.
+
 #include <glibmm/refptr.h>
 #include <glibmm/ustring.h>
 #include <glibmm/error.h>
@@ -49,7 +51,7 @@ namespace Glib
  * - less than operator
  * - greater than operator
  *
- * @note In most cases std::map or std::unordered_map is preferable.
+ * @deprecated Use std::map or std::unordered_map instead.
  *
  * @newin{2,24}
  */
diff --git a/tests/glibmm_btree/main.cc b/tests/glibmm_btree/main.cc
index dbe0f851..f2a1a478 100644
--- a/tests/glibmm_btree/main.cc
+++ b/tests/glibmm_btree/main.cc
@@ -1,5 +1,22 @@
+// Glib::BalancedTree is deprecated, but let's keep the test.
+// The recommended replacement is std::map or std::unordered_map
+// which requires no test here.
+#undef GLIBMM_DISABLE_DEPRECATED
+
 #include <glibmm.h>
 
+#ifdef GLIBMM_DISABLE_DEPRECATED
+int
+main(int, char**)
+{
+  // If glibmm is configured with build-deprecated-api=false, GLIBMM_DISABLE_DEPRECATED
+  // is defined in glibmm.h (actually in glibmmconfig.h). The undef at the start of
+  // this file has no effect.
+  return 77; // Tell Meson's test harness to skip this test.
+}
+
+#else
+
 using type_key_value = Glib::ustring;
 using type_p_key_value = type_key_value*;
 
@@ -223,3 +240,4 @@ main()
 
   return EXIT_SUCCESS;
 }
+#endif // GLIBMM_DISABLE_DEPRECATED


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]