Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2003-11-15 20:32:42


Hi Aleksey,

> If you have to care about broken compilers, I
> would recommend you to use 'bind' and 'select1st's metafunction-class form
> instead:
>
> typedef apply2<
> bind1<select1st<>,_2>
> , char
> , pair<int,bool>
> >::type res;
>
> BOOST_MPL_ASSERT_IS_SAME(res,int);
>
> This one is guaranteed to work for all library templates.

It turnes out that this workaround doesn't work with gcc 3.3. The following
code doesn't compile:

typedef mpl::vector4<
    mpl::pair<int, int*>,
    mpl::pair<short, short*>,
    mpl::pair<long, long*>,
    mpl::pair<char, char*>
> pairs;

typedef mpl::find_if<
    pairs,
    boost::is_same<mpl::bind1<mpl::select1st<>, mpl::_>, long> >::type iter;

BOOST_MPL_ASSERT_NOT_SAME(iter, mpl::end<pairs>::type);

On the other hand, gcc 3.3 doesn't need any workarounds, and one can use
select1st directly. Does this mean that I need #ifdef here, and which would
be the right configuration constant to use?

Thanks,

Arkadiy


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