Boost logo

Boost Users :

Subject: [Boost-users] [iterators ]bug?
From: bismuth_at_[hidden]
Date: 2009-03-04 14:44:13


There is probably a bug in boost::iterators library.
boost::transform_iteartor degrade stl iterator_category.
There is a code below, illustrating a problem(using VS2008 c++
compiler):

---------------------
#include <stdio.h>
#include <tchar.h>

#include <vector>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/static_assert.hpp>

struct Tr1:
    std::unary_function<unsigned, unsigned>
{
    unsigned operator()(unsigned a)const
    {
        return a;
    }
};

int _tmain(int argc, _TCHAR* argv[])
{
    typedef std::vector<unsigned>::iterator some_ra_iterator_t;
    typedef boost::transform_iterator<Tr1, some_ra_iterator_t> tr_iter_t;

    BOOST_STATIC_ASSERT
    (( boost::is_convertible
        < std::iterator_traits<some_ra_iterator_t>::iterator_category,
            std::random_access_iterator_tag
>::value
    ));

    BOOST_STATIC_ASSERT
    (( ! boost::is_convertible
        < std::iterator_traits<tr_iter_t>::iterator_category,
            std::random_access_iterator_tag
>::value
    ));

    BOOST_STATIC_ASSERT
    (( boost::is_same
        < std::iterator_traits<tr_iter_t>::iterator_category,
            boost::detail::iterator_category_with_traversal
            < std::input_iterator_tag, //?!
                boost::random_access_traversal_tag
>
>::value
    ));

    return 0;
}
---------------------


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