[Boost.Iterators] iterator_facade + a class design issue
Dear all, I've decided to write an ABC named BasicIterator, from which all derived iterators are to be descended. The reason being that I have to refer to iterators inside an interface and I need a general base type as a place holder to which I can refer. Besides, I don't want to use CRTP in the interface, but I don't care if I'm forced to use it inside BasicIterator. As discussed in the interoperability section of iterator_facade (herehttp://www.boost.org/libs/iterator/doc/iterator_facade.html#interoperability), the euqal() function must be templatized. The problem is that I have to make equal() a pure virtual member function in order to force derived types override it, but templated virtual functions on the other hand, are not valid. So I was wondering what the best approach is. How can I achieve both of these goals? Please advise. Any ideas/suggestions are welcome. Thanks in advance
Ashkan Aliabadi
Dear all,I've decided to write an ABC named BasicIterator, from which all
derived iterators are to be descended. The reason being that I have to refer to iterators inside an interface and I need a general base type as a place holder to which I can refer. Besides, I don't want to use CRTP in the interface, but I don't care if I'm forced to use it inside BasicIterator.As discussed in the interoperability section of iterator_facade (here), the euqal() function must be templatized. The problem is that I have to make equal() a pure virtual member function in order to force derived types override it, but templated virtual functions on the other hand, are not valid.So I was wondering what the best approach is. How can I achieve both of these goals? Please advise.Any ideas/suggestions are welcome.Thanks in advance You might want to take a look at any_range from oven library (http://p-stade.sourceforge.net/oven/doc/html/oven/ranges.html#oven.ranges.an...) or any_iterator from adobe opensource library (http://stlab.adobe.com/classadobe_1_1any__iterator.html). Both of them provide convenient way for declaring methods in interface classes that return or accept ranges of values. HTH, Roman Perepelitsa.
Thanks a lot. I appreciate the help :) On Fri, Mar 7, 2008 at 2:53 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
Ashkan Aliabadi
writes: Dear all,I've decided to write an ABC named BasicIterator, from which
all derived iterators are to be descended. The reason being that I have to refer to iterators inside an interface and I need a general base type as a place holder to which I can refer. Besides, I don't want to use CRTP in the interface, but I don't care if I'm forced to use it inside BasicIterator.As discussed in the interoperability section of iterator_facade (here), the euqal() function must be templatized. The problem is that I have to make equal() a pure virtual member function in order to force derived types override it, but templated virtual functions on the other hand, are not valid.So I was wondering what the best approach is. How can I achieve both of these goals? Please advise.Any ideas/suggestions are welcome.Thanks in advance
You might want to take a look at any_range from oven library ( http://p-stade.sourceforge.net/oven/doc/html/oven/ranges.html#oven.ranges.an... ) or any_iterator from adobe opensource library (http://stlab.adobe.com/classadobe_1_1any__iterator.html). Both of them provide convenient way for declaring methods in interface classes that return or accept ranges of values.
HTH, Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Following node_iter example of iterator_facade
(herehttp://www.boost.org/libs/iterator/doc/iterator_facade.html#tutorial-example),
how can I wrap that inside an any_iterator? I'm really having a hard time
figuring that out. I'm using an any_iterator implementation by Thomas Becker
(herehttp://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/s...).
I would really appreciate it if anyone could give me a hand.
Regards
On Fri, Mar 7, 2008 at 10:28 AM, Ashkan Aliabadi
Thanks a lot. I appreciate the help :)
On Fri, Mar 7, 2008 at 2:53 AM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
Ashkan Aliabadi
writes: Dear all,I've decided to write an ABC named BasicIterator, from which
all derived iterators are to be descended. The reason being that I have to refer to iterators inside an interface and I need a general base type as a place holder to which I can refer. Besides, I don't want to use CRTP in the interface, but I don't care if I'm forced to use it inside BasicIterator.As discussed in the interoperability section of iterator_facade (here), the euqal() function must be templatized. The problem is that I have to make equal() a pure virtual member function in order to force derived types override it, but templated virtual functions on the other hand, are not valid.So I was wondering what the best approach is. How can I achieve both of these goals? Please advise.Any ideas/suggestions are welcome.Thanks in advance
You might want to take a look at any_range from oven library ( http://p-stade.sourceforge.net/oven/doc/html/oven/ranges.html#oven.ranges.an... ) or any_iterator from adobe opensource library (http://stlab.adobe.com/classadobe_1_1any__iterator.html). Both of them provide convenient way for declaring methods in interface classes that return or accept ranges of values.
HTH, Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ashkan Aliabadi
Following node_iter example of iterator_facade (here), how can I wrap that
inside an any_iterator? I'm really having a hard time figuring that out. I'm
using an any_iterator implementation by Thomas Becker (here). I would really
appreciate it if anyone could give me a hand.Regards
You should use iterator_facade to create new types of iterators (for example, if
you have your own data structure and want to provide iterator based access to
its elements). This is one part of the story. Another part is any_iterator. It's
just an iterator that any other iterator can be convertible to. You don't need
to add support for any_iterator in your own iterator (that you probably create
using iterator_facade); any_iterator will just work with any iterator type (even
ones from STL).
Here is an example of how you can use any_iterator.
#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#include
participants (2)
-
Ashkan Aliabadi
-
Roman Perepelitsa