Topic: implementation of lambda-functionals in std C++ (was: lambda functions proposal)
Author: Petter Urkedal <petter@matfys.lth.se>
Date: 1998/11/28 Raw View
The idea is inspiring. But these lambda-functions, can be implemented
with expression templates, with a syntax not so far from that of the
original post.
Here is a useless example:
template<typename Iterator1, typename Iterator2>
void useless_transform(Iterator1 u, Iterator1 u_end, Iterator2 v) {
placeholder<0, int> i;
placeholder<1, int> j;
placeholder<2, int> k;
transform(u, u_end, v,
lambda(i, apply(lambda(j, k, j*k),
i+value(10), i-value(10))));
}
A working implementation can be found at
http://matfys.lth.se/~petter/src/more/stlext/index.html
along with some examples. It's not so fully debugged, as it was done
yesterday, inspired by the present discussion. (The examples builds
with egcs and DEC cxx, at least.)
Of course, build-in lambda expressions would be faster and give nicer
compiler messages. So I'm not taking an opinion against the proposal.
-petter.
--
[- http://matfys.lth.se/~petter/ -]
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]