The threshold argument in the search_atleast method is meant to be unrelated to the ELTYPE or KEYTYPE types, respectively.
2020-08-02 Bruno Haible <br...@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. diff --git a/lib/gl_omap.hh b/lib/gl_omap.hh index 1f892e4..903befb 100644 --- a/lib/gl_omap.hh +++ b/lib/gl_omap.hh @@ -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); } diff --git a/lib/gl_oset.hh b/lib/gl_oset.hh index 5a72476..157b8b9 100644 --- a/lib/gl_oset.hh +++ b/lib/gl_oset.hh @@ -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); }