Hicham,
please see my comments below:
Hello,
I have a question about tag dispatching (for e.g. the std::advance() function in the std lib, as described for instance in http://www.boost.org/community/generic_programming.html#tag_dispatching)
1. The call to
detail::advance_dispatch(i, n, category);
I don't understand. category is a type not an object, it should be category(), right?
typename iterator_traits<InputIterator>::iterator_category category;here is no typedef used, so category is an instance of iterator_category. In the template context you have to prefix it with typename keyword. Using:
detail::advance_dispatch(i, n, category);
typename iterator_traits<InputIterator>::iterator_category category();declares a function, which returns iterator_category, but does not create a class instance.
2. If I am correct,
the tags are empty structs which I assume allows modern compilers
(g++4, msvc8/9, intel) to optimize away the creation of that category object ?
3. If i am still correct, I have a tag which has no members except 1 static function that returns void.
Would that optimization still apply?
regards,