
From: FlSt@gmx.de
The new Perl 6 has a nice feature called junctions. See http://www.perl.com/pub/a/2003/07/29/exegesis6.html?page=4 and http://www.metaperl.com/talks/p6-junctions/ for more information. I think this is a interesting way to save the time for writing loops in some situations. I've tried to implement this for C++ and uploaded a version with two examples into the Boost Sandbox File Vault (flos_super_position.zip). This version works for my purposes, but if you interested i would rework it and submit it to the boost library.
I have a few questions about your design: Why "super position" versus Perl's "junction?" When describing the enumerators, you use the Perl terminology, apparently because it makes sense. Frankly, I don't "get" "super position." Why is the junction type a template parameter? Did you consider making four separate types? Does using one make it easier to compare instances of the four types? Should the client have to care about that? IOW, I think writing disjunction<T> is simpler and clearer than super_position<ANY, T>. Other name possibilities like "any_of" are possible, too. Why would one change the Container parameter? Why would the client of this class care about the associative container being used to implement it? I noted that you wrote your loops to repeatedly evaluate x.end(). Algorithms avoid that problem; if you need your own loops, you should hoist calls to end() out of the loop. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;