
"Anatoli Tubman" <anatoli@ptc.com> wrote in message news:4087D552.8000209@ptc.com... | John Torjo wrote: | > | > However, had I used | > crange<int> r(d); // how do I know what iterators to keep inside? | > crange<int> r(v); // how do I know what iterators to keep inside? [snip] | Another option is to write | | for (crange<int>& r = mkrange(d); r; ++r) { ... } | | where mkrange returns crange_impl<int, d_array> which is derived from | crange<int>. | | This doesn't need heap allocation, but still needs virtual operator++ | and virtual operator*. A smart compiler could in theory inline them | anyway, but I wouldn't count on it. virtual dispatching would be most unfortunate here. What about letting crange's constructor take a pointer to crange_impl and forward to crange_impl::operator++() inside crange_impl::operator++() ? br Thorsten