Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2003-11-27 00:30:56


Hi MPL experts,

Unfortunately, I was without Internet connection for a few days, and unable
to continue this discussion. Now that I got it back, for some reason I
can't find in Boost archives any traces of the post on the subject by David
Abrahams, which I read prior to loosing the connection... So I apologize
for not being able to use it in this post.

Anyway, I was trying to find out what would be a PORTABLE way to use
mpl::select1st/2nd in a lambda expression. I already converted all our
meta-programming code to use MPL, and, since we do use mpl::pair in quite a
few places, such functions as select1st, select2nd, etc., are quite
important to us.

The problem is that on a deficient compiler, such as VC6, an intrusive
mechanism is used, which causes select1st to instantiate, and it requires
for

typedef ... first;

be defined in its parameter. So such constructs like select1st<_1> cause
VC6 to complain about lack of "first" typedef in _1.

Aleksey suggested to substitute all the stuff with transformed_view, which
works in the example I provided, but probably can't be considered a
universal approach, since how would we use it if we needed both 1st and 2nd
elements of the pair?

The workaround I suggested was to define a wrapper which would provide a
fake "first" typedef just to satisfy VC6 with no change to anything else,
that could be defined and used something like:

template<class T> struct fake1st : T
{
typedef int first;
};

select1st<fake1st<_1> > // only use it like this in a lambda expression

Pretty much like working around ETI.

David didn't like it, and, although I still think that this could work
cleanly with both deficient an conforming compilers (I tried it with VC6 and
GCC 3.3), I will not use it unless the authors of MPL agree with me, since I
would not like at all to hack MPL, and since I do admit that my
understanding of underlying mechanisms is too far from perfect.

But in this case the question still remains:

- How to make the code that uses select1st in a lambda expression work with
both conforming and deficient compilers (preferrably with no #ifdefs)?
- If an #ifdef is needed, which configuration constant should be used?

Thanks for your help,

Arkadiy


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