Boost logo

Boost Users :

Subject: [Boost-users] challange to MPL gurus
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-12-12 14:41:09


I am trying to implement concept checking for a couple of MPL concepts as
part of a large project. I've having a heck of a time with some aspects of
this.

The example below illustrates one of the problems I'm having.
The intent is to test the concept. for next<I>, the concept
check is invoked recurrsively until the end of iteration is
encountered. (I'm assuming it's a list in this test). But the
is_end<false_> branch is always invoked leading to failure
on both MSVC 9.0 and gcc 4.5.3 compilers

I'll be quite impressed with anyone who can figure out
how to make this work.

Robert Ramey

template<typename I>
struct ForwardIterator {
    template<typename B>
    struct is_end {};
    template<>
    struct is_end<false_> {
        typedef typename deref<I>::type t1;
        typedef typename next<I>::type t2;
        BOOST_CONCEPT_ASSERT(( ForwardIterator<t2> ));
    };
    typedef typename boost::mpl::print<
        I
>::type t1;
    typedef typename is_end<
        typename boost::is_same<
            boost::mpl::l_iter<boost::mpl::l_end>,
            I
>
> type;
        BOOST_MPL_ASSERT((
                is_convertible<
                    typename I::category,
                    forward_iterator_tag
>
        ));
};

template<typename S>
struct ForwardSequence {
    typedef typename end<S>::type t2;
    BOOST_CONCEPT_ASSERT(( ForwardIterator<t2> ));
};

#include <boost/mpl/list.hpp>
void test_list_sequence(){
    BOOST_CONCEPT_ASSERT(( boost::mpl::ForwardSequence<
            boost::mpl::list<int, char>
>
    ));
}


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