Hi all,
I've finally reworked the generic lambda patches I made back in 2009
(http://gcc.1065356.n5.nabble.com/lambda-Latest-experimental-polymorphic-lambda-patches-tt713016.html)
to apply against GCC's mainline.
The syntaxes demonstrated by the following examples are supported (as
per the previous incarnation) implementing parts of N3559 and N3560.
1. [] (auto x, auto& y, auto const& z) { return x + y + z; }
2. [] <typename X, typename Y, typename Z> (X x, Y& y, Z const& z) { return
x + y + z; }
3. [] <typename Y> (auto x, Y& y, auto const& z) { return x + y + z; }
Missing features:
- Conversion to function pointer of stateless generic lambdas is
currently unsupported. Currently a warning is generated for all
such lambdas at their definition.
Other issues: (see XXX, FIXME, TODO)
a) Location of implementation.
b) What to do about name mangling?
c) Figure out why symtab contains nullptrs. Maybe related to (b).
d) Not behind any -std option. Should require -std=c++1y or
-std=gnu++1y.
e) Should collect 'auto' parameters during parse and realloc
template parameter list once at the end of the parameter list
rather than incrementally.
Any comments appreciated. Guidance on implementing the conversion
operator for stateless generic lambdas would be useful. I've made a
few attempts which were lacking!
Cheers,
Adam
Patch summary: (4):
[lambda] [polymorphic] Support template-parameter-list in
lambda-declarator.
[lambda] [polymorphic] Support generic lambdas in templates.
[lambda] [polymorphic] Infer template parameter from auto used in
function parameter list.
[lambda] [polymorphic] [HACK] Avoid crash on symbol table writing when
generic lambda declared with iostream (or potentially other code)
included.
gcc/cp/decl.c | 1 +
gcc/cp/mangle.c | 2 +
gcc/cp/parser.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++++++--
gcc/cp/pt.c | 10 +++
gcc/cp/semantics.c | 10 ++-
gcc/symtab.c | 18 ++++
6 files changed, 279 insertions(+), 8 deletions(-)
--
1.8.3