Re: [Boost-users] Placeholders and iterator arithmetic in MPL
Steven Watanabe wrote:
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.
Indeed, thank you! One of my previous attempts was written to avoid
the past-the-end, or so I thought... But [slaps forehead] I somehow
was thinking that reverse_iter_fold would give reverse_iterators, like
those found in the STL. Whereas, next<> and prior<> always operate
forwards. So, I had them mixed up.
This little example does the job neatly:
template<class T>
struct works : reverse_iter_fold<
T,
vector_c<long>,
push_front<_1,
if_
{};
It substitutes a long_<0> for the first step of the reverse_iter_fold, when next<> would be past the end. It could be adapted to iter_fold when using prior<>. Dave Abrahams wrote:
stylistically, may I suggest
struct fails : reverse_iter_fold< .... > {};
You're right to correct me -- I should know that since I have the (your) book! Thank you both for your help, Rob
participants (1)
-
Rob Platt