Opened 10 years ago

#6977 new Bugs

bug in conversion of mpl iterator category tags

Reported by: Robert Ramey Owned by: Joel Falcou
Milestone: To Be Determined Component: mpl
Version: Boost 1.49.0 Severity: Problem
Keywords: mpl category convert Cc:

Description

MPL documentation indicates that bidirectional_iterator_tag is convertible to random_access_iterator_tag. The following code shows that this is not true.

#include <boost/mpl/iterator_category.hpp>
#include <boost/mpl/iterator_tags.hpp>

#include <boost/mpl/print.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_convertible.hpp>

using namespace boost::mpl;

print<
    boost::is_convertible<
        bidirectional_iterator_tag,
        random_access_iterator_tag
    >::type
> x5;

BOOST_MPL_ASSERT((
    boost::is_convertible<
        bidirectional_iterator_tag,
        random_access_iterator_tag
    >
));

The compile time output from this progam is:

1>------ Build started: Project: test_interval, Configuration: Debug Win32 ------
1>Compiling...
1>test_multi_precision.cpp
1>c:\boostrelease\boost\mpl\print.hpp(51) : warning C4308: negative integral constant converted to unsigned type
1>        c:\projects\boost projects\mpl\tests\test_multi_precision.cpp(15) : see reference to class template instantiation 'boost::mpl::print<T>' being compiled
1>        with
1>        [
1>            T=boost::integral_constant<bool,false>::type
1>        ]
1>c:\projects\boost projects\mpl\tests\test_multi_precision.cpp(22) : error C2664: 'boost::mpl::assertion_failed' : cannot convert parameter 1 from 'boost::mpl::failed ************boost::is_convertible<From,To>::* ***********' to 'boost::mpl::assert<false>::type'
1>        with
1>        [
1>            From=boost::mpl::bidirectional_iterator_tag,
1>            To=boost::mpl::random_access_iterator_tag
1>        ]
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>Build log was saved at "file://c:\Projects\Boost Projects\mpl\tests\vcide\Debug\BuildLog.htm"
1>test_interval - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Robert Ramey

Change History (0)

Note: See TracTickets for help on using tickets.