Boost logo

Boost Users :

Subject: [Boost-users] Strange iterator_traits of iterator_facade
From: Swerts, Benjamin (Benjamin.Swerts_at_[hidden])
Date: 2010-02-23 11:52:20


Hello all,

I have a class that is templated on an iterator type. As it only works
with bidirectional and random access iterators, I thought I would impose
that as follows:

template<typename T> class A
{
  A() { checkIterator(std::iterator_traits<T>::iterator_category()); };

  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 ) {};
};

This works when T is a standard iterator but not when it's one of my
iterator_facade subclasses. For example:

class const_iterator : public iterator_facade<const_iterator, const B,
boost::random_access_traversal_tag, B>

When using this class with A<const_iterator> I get a linker error
because the checkIterator function is called with:

boost::detail::iterator_category_with_traversal<struct
std::input_iterator_tag,struct boost::random_access_traversal_tag>

I certainly cannot add a specialization of checkIterator with this tag
to class A.
Could anyone shed some light on this problem? I'm working with Boost
1.39.0 on MSVC2008SP1.
Thanks a lot in advance!

Greets,

        Ben


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