Placeholders and iterator arithmetic in MPL
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
AMDG Rob Platt wrote:
I can successfully instantiate this with, for example, vector_c
. 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?
After I included all the right headers, it compiled for me. The only problem is that you're dereferencing past the end of the sequence. In Christ, Steven Watanabe
On Wed, Aug 18, 2010 at 7:23 AM, Steven Watanabe
AMDG
Rob Platt wrote:
struct fails { typedef typename reverse_iter_fold< T, vector_c<long>, push_front<_1, deref< next<_2> > > >::type type; };
and stylistically, may I suggest struct fails : reverse_iter_fold< .... > {}; ? Cheers -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (3)
-
Dave Abrahams
-
Rob Platt
-
Steven Watanabe