[iter] Start prototyping hb_copy()
This commit is contained in:
parent
44af738d19
commit
ad3ed58de5
|
@ -33,6 +33,7 @@ struct array_iter_t : hb_iter_t<array_iter_t<T>, T>
|
||||||
{
|
{
|
||||||
array_iter_t (hb_array_t<T> arr_) : arr (arr_) {}
|
array_iter_t (hb_array_t<T> arr_) : arr (arr_) {}
|
||||||
|
|
||||||
|
typedef T __item_type__;
|
||||||
T& __item_at__ (unsigned i) const { return arr[i]; }
|
T& __item_at__ (unsigned i) const { return arr[i]; }
|
||||||
bool __more__ () const { return arr.len; }
|
bool __more__ () const { return arr.len; }
|
||||||
void __forward__ (unsigned n) { arr += n; }
|
void __forward__ (unsigned n) { arr += n; }
|
||||||
|
@ -43,6 +44,18 @@ struct array_iter_t : hb_iter_t<array_iter_t<T>, T>
|
||||||
hb_array_t<T> arr;
|
hb_array_t<T> arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename S, typename D> static inline bool
|
||||||
|
copy (D &d, hb_iter_t<S> &s)
|
||||||
|
{
|
||||||
|
typename S::iter_t is = s.iter ();
|
||||||
|
typename D::iter_t id = d.iter ();
|
||||||
|
|
||||||
|
for (; d && s; ++d, ++s)
|
||||||
|
*d = *s;
|
||||||
|
|
||||||
|
return !d;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -56,10 +69,7 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
s2 = s;
|
s2 = s;
|
||||||
|
|
||||||
for (; s && t; ++s, ++t)
|
copy (t, s);
|
||||||
{
|
|
||||||
*t = *s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue