Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2003-03-14 02:22:30


Hi,

In some of my MPL-using code I needed set-based functionality. So I wrote a
function that does an insertion into an ordered list of constants. However,
it seems that if I compare a list created from a bunch of constants to an
explicit list, they don't end up the same. I've attached the example code
below.

I'm wondering whether somebody can spot any errors in my code, or that I'm
probably confused about the way types propagate through meta-functions
again.

All help is greatly appreciated.

Sincerely,

Jaap Suter

____________________________________

template < class N, class L >
struct add_to_sorted_list
{
    typedef typename mpl::if_<
        typename mpl::contains< L, N >::type,
        L,
        typename mpl::insert< L,
            typename mpl::lower_bound< L,
                N,
                mpl::less< mpl::_, mpl::_ >
>::type,
            N
>::type
>::type type;
};

typedef mpl::list_c< int, 0, 1, 2, 3 > list0;
typedef mpl::list_c< int, 0, 1, 3 > list1;
typedef add_to_sorted_list<
                mpl::integral_c< int, 2 >,
                list1,
>::type result;

BOOST_STATIC_ASSERT( is_same< list0, result >::value ); // THIS FAILS;


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk