]> Savannah Git Hosting - gnulib.git/commitdiff
oset-c++, omap-c++: Remove restriction for search_atleast method.
authorBruno Haible <bruno@clisp.org>
Sun, 2 Aug 2020 18:19:31 +0000 (20:19 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Aug 2020 18:22:22 +0000 (20:22 +0200)
* lib/gl_oset.hh (gl_OSet::search_atleast): Allow the threshold to be of
a different type than the element.
* lib/gl_omap.hh (gl_OMap::search_atleast): Allow the threshold to be of
a different type than the key.

ChangeLog
lib/gl_omap.hh
lib/gl_oset.hh

index 544563af287e00a859f95c1284d7b9809a15aea9..10d5227bfc17ac32697f2ad0019563062e586a8c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-08-02  Bruno Haible  <bruno@clisp.org>
+
+       oset-c++, omap-c++: Remove restriction for search_atleast method.
+       * lib/gl_oset.hh (gl_OSet::search_atleast): Allow the threshold to be of
+       a different type than the element.
+       * lib/gl_omap.hh (gl_OMap::search_atleast): Allow the threshold to be of
+       a different type than the key.
+
 2020-08-01  Paul Eggert  <eggert@cs.ucla.edu>
 
        gnumakefile: say ‘$(MAKE)’ not ‘make’
index 1f892e46f8134c859dce42198ee104b02ce588eb..903befb55d93cd16274894915984621223d8a3bd 100644 (file)
@@ -89,8 +89,9 @@ public:
      THRESHOLD is defined by the THRESHOLD_FN.
      Returns true and stores the found pair in KEY and VALUE if found.
      Otherwise returns false.  */
-  bool search_atleast (bool (*threshold_fn) (KEYTYPE * /*key*/, KEYTYPE * /*threshold*/),
-                       KEYTYPE * threshold,
+  template <typename THT>
+  bool search_atleast (bool (*threshold_fn) (KEYTYPE * /*key*/, THT * /*threshold*/),
+                       THT * threshold,
                        KEYTYPE *& key, VALUETYPE *& value) const
   { return gl_omap_search_atleast (_ptr, reinterpret_cast<gl_mapkey_threshold_fn>(threshold_fn), threshold, &key, &value); }
 
index 5a72476229c57335a7fcc4218e77e017d7e60405..157b8b995bcc614d43a72da4f73c0ca7842c5892 100644 (file)
@@ -80,8 +80,9 @@ public:
      by the THRESHOLD_FN.
      Returns true and store the found element in ELT if found, otherwise returns
      false.  */
-  bool search_atleast (bool (*threshold_fn) (ELTYPE * /*elt*/, ELTYPE * /*threshold*/),
-                       ELTYPE * threshold,
+  template <typename THT>
+  bool search_atleast (bool (*threshold_fn) (ELTYPE * /*elt*/, THT * /*threshold*/),
+                       THT * threshold,
                        ELTYPE *& elt) const
   { return gl_oset_search_atleast (_ptr, reinterpret_cast<gl_setelement_threshold_fn>(threshold_fn), threshold, &elt); }