> While I do agree O(1) is better than O(N), I would like to point out that it > is usable only when the pseudo-variadic template interface is used (i.e., > variant<T1, T2, ..., TN> as opposed to variant<Types>).
Why? And to be absolutely clear: what do you mean by "it"? > Also, I am still not convinced that an unrolled if-else implementation would > not be optimized in the same manner as a switch statement. That is, whether I do not know how smart are modern optimizers. But in general my understnding was that if-else form should use O(N) comparisons, while switch form should be compiled into jump with some computed offset. > Further, I would like to point out that we are debating integer O(1) vs. > O(N) for integer-equality comparisons. While I am a proponent of limiting > complexity, I would like to observe that you yourself suggested a cap N = > 128. > > In sum, I'm not sure how pertinent this issue is at this point. I agree that by itself the difference is not that significant. But note that visitation is very basic operation in regards to variant type. Almost any activity that involve variant will include some kind of visitation (look into your implementation for example). Some people fight to eliminate extra level of indirection by using references vs. pointers. Or eliminate virtual function to prevent double resolution. In this case the difference could be much more significant (up to 128 times). So unless it's really unreasonably difficult to implement different visitation scheme, I see enough point to try to do this. Gennadiy. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost