[iter] Constrain hb_fill() and hb_copy()
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 8 Jan 2019 21:00:06 +0000 (13:00 -0800)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 21 Jan 2019 01:12:12 +0000 (20:12 -0500)
src/hb-iter.hh

index d8a2a82..93f4199 100644 (file)
@@ -194,15 +194,19 @@ struct hb_is_iterator_of { enum {
  * Algorithms operating on iterators or iteratables.
  */
 
-template <typename C, typename V> inline void
+template <typename C, typename V> inline
+  hb_enable_if_t (hb_is_iterable (C),
+void)
 hb_fill (C& c, const V &v)
 {
   for (typename C::iter_t i (c); i; i++)
     hb_assign (*i, v);
 }
 
-template <typename S, typename D> inline bool
-hb_copy (hb_iter_t<D> &id, hb_iter_t<S> &is)
+template <typename S, typename D> inline
+  hb_enable_if_t (hb_is_iterator (S) && hb_is_iterator (D),
+bool)
+hb_copy (D id, S is)
 {
   for (; id && is; ++id, ++is)
     *id = *is;