|
Boost Users : |
Subject: Re: [Boost-users] Strange iterator_traits of iterator_facade
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-26 10:41:43
AMDG
Swerts, Benjamin wrote:
>> Swerts, Benjamin wrote:
>>
>>> template<typename Tag> void checkIterator( Tag );
>>> void checkIterator( std::bidirectional_iterator_tag ) {};
>>> void checkIterator( std::random_access_iterator_tag ) {};
>>> void checkIterator( boost::random_access_traversal_tag ) {}; };
>>>
>> Try just having a single overload:
>>
>> void checkIterator(std::bidirectional_iterator_tag) {}
>>
>
> Unfortunately that doesn't work. Now it complains also about regular
> random access iterators. Tags are apparently not automatically converted
> into each other.
>
Yes they can.
#include <iterator>
void checkIterator(std::bidirectional_iterator_tag) {}
int main() {
checkIterator(std::random_access_iterator_tag());
}
> Maybe I should keep the single templated checkIterator function and
> determine the type of the tag using some MPL magic? I doubt I could come
> up with such a solution myself as I never used it before. I made some
> tests with boost::mpl::iterator_category but it looks like the iterator
> should typedef 'category' instead of 'iterator_category'.
>
Did you leave the templated overload?
If you did, it will usually win in overload resolution.
Do you really want a link error instead of a
compiler error?
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net