Boost logo

Boost Users :

Subject: [Boost-users] Placeholders and iterator arithmetic in MPL
From: Rob Platt (rob.j.platt_at_[hidden])
Date: 2010-08-18 00:48:13


Hello folks. I'm trying to use the iter_fold and reverse_iter_fold
algorithms in MPL, since I want to operate on sub-ranges of an input
sequence. Now if I do just the trivial case of dereferencing the
current element, then all is well:

struct works
{
        typedef typename reverse_iter_fold<
                T,
                vector_c<long>,
                push_front<_1,
                        deref< _2 >
> >::type type;
};

I can successfully instantiate this with, for example,
vector_c<int,1,2,3,4>. But when I do iterator arithmetic (e.g. prior,
next or begin) I run into trouble:

struct fails
{
        typedef typename reverse_iter_fold<
                T,
                vector_c<long>,
                push_front<_1,
                        deref< next<_2> >
> >::type type;
};

-- error messages about arg 3 - I suspect that prior is being applied
to the placeholder arg type itself, not to the iterator. I'm wondering
if I should be using lambda/apply, but I've tried that without
success. What's a would-be template metaprogrammer to do?

Regards
Rob


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