
Hello, I've read the article of ranges vs. iterators from Andrei Alexandrescu and I've start to implement something similar and wanted to extend the idea to 2D grids (popFront, front, popLine). OK, I now s/g similar can be achieved using iterators(ranges) returning iterators(ranges) as the current item, I was just simple experimenting. Using the iterator_category concept empty structs are used to check, select functions at compile time. struct A {}; struct B : A {} void foo( A ) { alg1... } void foo( B ) { alg2... specialized for B } template<typename T> void foofoo( T ){ foo( getCategory<T>() ); } My first idea was to use multiple inheritance, but it result error (ambiguous call) struct A {}; struct B : A {}; struct A2 : A {}; struct B2 : A2, B {}; void foo( A ) { alg1... } void foo( B ) { alg2... specialized for B } void foo( A2 ) { alg3... specialized for A2 } void g() { B2 b; f(b); } // error: is it f(B) or f(A2) Than I've used cast operators and inheritance stating that, a B2 is mainly an A2 and secondly a B: struct A {}; struct B : A {}; struct A2 : A {}; struct B2 : A2 { operator B() { return B(); } }; void foo( A ) { alg1... } void foo( B ) { alg2... specialized for B } void foo( A2 ) { alg3... specialized for A2 } void g() { B2 b; f(b); } // shall call f(A2) So my question is that, is it a working method, or the whole concept is wrong ? Has anyone used something similar ? If so, is there some sample codes/results? Thank you, Gzp -- View this message in context: http://old.nabble.com/iterator_category%3E-algorithm-selection-with-cast-ope... Sent from the Boost - Dev mailing list archive at Nabble.com.