For example,
1) parser to match any value requires template lambda:
auto r_any = template<class Iterator>[](Iterator i1, Iterator i2)
{
return axe::make_result(i1 != i2, i1 + 1, i2);
}
2) parser to match nested c-style comment requires recursion:
auto c_comment = template<class Iterator>[](Iterator i1, Iterator i2)
{
// operators are overloaded for parser rules
return ("/*" & *(*(r_any - "/*" - "*/") | c_comment) & "*/")(i1,
i2);
};
<side-note>
It would have been even better if recursion was allowed for auto
declaration in general:
auto c_comment = "/*" & *(*(r_any - "/*" - "*/") | c_comment) & "*/";
</side-note>
It can be done with hand-written functors, why not lambdas? Were those
features considered including in the c++0x? If they were rejected,
what was the reason?
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Herb Sutter commented on polymorphic lamdas in the lates C9 interview:
http://herbsutter.com/2011/06/07/c9-ama/
->
http://channel9.msdn.com/Shows/Going+Deep/Herb-Sutter-C-Questions-and-Answers
->
"Polymorphic lambdas - why did they fail and what work is being done
to bring something like them back?"
http://channel9.msdn.com/Shows/Going+Deep/Herb-Sutter-C-Questions-and-Answers#time=0h20m40s
cheers,
Martin
--
Stop Software Patents
http://petition.stopsoftwarepatents.eu/841006602158/
http://www.ffii.org/